javascript - window.print() - 不打开打印窗口

标签 javascript printing

<分区>

Possible Duplicate:
“Silent” Printing in a Web Application

我希望 window.print() 命令直接打印,而不打开打印窗口:

enter image description here

这可能吗?

最佳答案

尝试

对于 Mozilla:http://forums.mozillazine.org/viewtopic.php?t=48336

在IE中使用JavaScript的window.print()打印网页时,默认会弹出IE的打印机对话框。为避免这种情况,请使用以下 JavaScript 代码:

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();
}

来自:http://www.devx.com/tips/Tip/30834

关于javascript - window.print() - 不打开打印窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11391178/

相关文章:

python - 仅打印 .txt 文件中的特定单词 - Python

javascript - 获取当前在 angularjs 中使用的 Controller

javascript - 过滤产生错误结果 Angularjs

javascript - 刷新所有窗口中的所有选项卡

python - 通过文本宽度获取单词的打印长度

powershell - Powershell Out-Printer破坏了“格式表”列的布局

javascript - extjs4 动态更改操作列图标

javascript - list 文件中的 update_url 禁用我的 chrome 扩展

c - 如何使用C仅将更改的字符打印到控制台

C 编程为什么我的代码不能使用嵌套结构数组打印正确的输出?