如何使用 Javascript 或 Jquery 以编程方式调用“打印预览”屏幕?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7303705/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I programmatically call the "Print Preview" screen using Javascript or Jquery?
提问by bhavinp
Possible Duplicate:
How can Print Preview be called from Javascript?
可能的重复:
如何从 Javascript 调用打印预览?
I have a button on the screen which should call a JavaScript function.
我在屏幕上有一个按钮,它应该调用一个 JavaScript 函数。
<input class="btn-print" type="button" value="Print" onclick="PrintPreview()">
This should open a new window with the Print Preview screen, just as you would if you went to File>Print>Print Preview in FF. File>Print Preview in IE.
这应该会打开一个带有打印预览屏幕的新窗口,就像您在 FF 中转到文件>打印>打印预览一样。IE 中的文件>打印预览。
回答by Icarus
No can do. The most you can do with javascript is
没有办法。你可以用javascript做的最多的是
window.print();
To popup the print dialog.
弹出打印对话框。
回答by Josh Mein
This is a feature of the browser and it would be a security risk to allow it. Therefore, most browsers will not allow it.
这是浏览器的一项功能,允许它存在安全风险。因此,大多数浏览器都不允许。
how-can-print-preview-be-called-from-javascriptis another question that asked the same thing.
how-can-print-preview-be-call-from-javascript是另一个提出同样问题的问题。