http://blog.csdn.net/rongyongfeikai2/article/details/8460598

————————————————————————————————————————————————————————————————————————————————

首先,要定义两个button,打印和打印预览按钮。

[javascript] view plaincopy
  1. <input type="button" value="打印" onclick="print()"/><input type="button" value="打印预览" onclick="printPreivew()"/>  


然后,在页面中定义一个Object,这个是打印的关键。

  1. <OBJECT id="WebBrowser1" height=width=classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb></OBJECT>  


然后,再写javascript语句:

[javascript] view plaincopy
  1. //打印  
  2.     function print(){  
  3.           
  4.         document.getElementById("WebBrowser1").execWB(6,1);  
  5.     }  
  6.     //打印预览  
  7.     function printPreivew(){  
  8.           
  9.         document.getElementById("WebBrowser1").execWB(7,1);  
  10.     }  


 

posted on 2015-11-17 14:17  网络大豆  阅读(745)  评论(0编辑  收藏  举报