window.print() - 无需打开打印窗口 [英] window.print() - without opening the print window
本文介绍了window.print() - 无需打开打印窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
使用时JavaScript的
window.print()
要在IE中打印网页,默认情况下会提示IE的打印机对话框。要避免这种情况,请使用以下JavaScript代码:if(navigator.appName ==Microsoft Internet Explorer)
{
var PrintCommand ='< object ID =PrintCommandObjectWIDTH = 0 HEIGHT = 0
CLASSID =CLSID:8856F961-340A-11D0-A96B-00C04FD705A2>< / object> ;
document.body.insertAdjacentHTML('beforeEnd',PrintCommand);
PrintCommandObject.ExecWB(6,-1); PrintCommandObject.outerHTML =;
}
else {
window.print();
}
来自: http://www.devx.com/tips/Tip/30834
Possible Duplicate:
“Silent” Printing in a Web ApplicationI'd like the
window.print()
command to print directly, without opening the print window:Is that possible?
解决方案try
For Mozilla : http://forums.mozillazine.org/viewtopic.php?t=48336
When you use JavaScript's
window.print()
to print a Web page in IE, by default, it prompts IE's printer dialog box. To avoid this, use the following JavaScript code:if (navigator.appName == "Microsoft Internet Explorer") { var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>'; document.body.insertAdjacentHTML('beforeEnd', PrintCommand); PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = ""; } else { window.print(); }
from : http://www.devx.com/tips/Tip/30834
这篇关于window.print() - 无需打开打印窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文