特别提示
运行本例代码,如果已经安装了打印机,将直接调用打印机打印页面,否则提示安装打印机。
1.用window对象的print方法
<button onClick="window.print()">打印</button>
2.用WebBrowser控件
<object id="WebBrowser" width=0 height=0
classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
<button onClick="WebBrowser.ExecWB(8,1)">打印</button>
3.在文档区域执行print命令
<button onClick="document.execCommand('print')">打印</button>