The example in this article describes how JavaScript calls the browser's print function. Share it with everyone for your reference. The details are as follows:
1. Universal type, supports IE, Firefox, Chrome...
2. Only supports IE printing:
<script> var print=function(){ /** * WebBrowser.ExecWB(1,1) 打开 * Web.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口 * Web.ExecWB(4,1) 保存网页 * Web.ExecWB(6,1) 打印 * Web.ExecWB(7,1) 打印预览 * Web.ExecWB(8,1) 打印页面设置 * Web.ExecWB(10,1) 查看页面属性 * Web.ExecWB(15,1) 好像是撤销,有待确认 * Web.ExecWB(17,1) 全选 * Web.ExecWB(22,1) 刷新 * Web.ExecWB(45,1) 关闭窗体无提示 */ document.getElementById('printer').ExecWB(6,1); } </script> <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id="printer" height="0" width="0"></OBJECT> <button onclick="print();">打印</button>
3. Control the print display area and paging style:
.noprint { display: none; } .nextpage { page-break-after: always; }
I hope this article will be helpful to everyone’s JavaScript programming design.