2010年10月15日   JavaScript   6,307 次浏览
使用JavaScript IE内置打印方法其实就是利用一个OBJECT对象而已。
废话不多说直接上代码,直接复制即可使用:
<html>
<head>
<style media=print>
.Noprint{display:none;}<!--用本样式在打印时隐藏非打印项目-->
.PageNext{page-break-after: always;}<!--控制分页-->
</style>
</head>
<body>
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
<center class="Noprint">
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
<input type=button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1)>
<input type=button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1)>
</center>
打印内容
</body>
</html> |
附上其他的一些常用方法:
WebBrowser.ExecWB(1,1) //打开 WebBrowser.ExecWB(2,1) //关闭现在所有的IE窗口,并打开一个新窗口 WebBrowser.ExecWB(4,1) //保存网页 WebBrowser.ExecWB(6,1) //打印 WebBrowser.ExecWB(7,1) //打印预览 WebBrowser.ExecWB(8,1) //打印页面设置 WebBrowser.ExecWB(10,1) //查看页面属性 WebBrowser.ExecWB(15,1) //撤销 WebBrowser.ExecWB(17,1) //全选 WebBrowser.ExecWB(22,1) //刷新 WebBrowser.ExecWB(45,1) //关闭窗体无提示 |
>>> Hello World <<<
这篇内容是否帮助到你了呢?
如果你有任何疑问或有建议留给其他朋友,都可以给我留言。