JS打印

//这些是js
    <script language="javascript">
      function printme()
     {
         var print = this.document.getElementById("print").innerHTML;
          print = print + "<link href=style1.css rel=stylesheet type=text/css>" +"<br/>"
         print = print +"<br/>"
     print = print +'<SCRIPT language=javascript> function printView(){hidden();document.all.WebBrowser.ExecWB(7,1); } function hidden(){document.all("printView").style.display="none"}<\/script>';
        print = print + "<OBJECT   classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2   height=21   id=WebBrowser   width=87></OBJECT> <input type=image id=printView name=Button src=images/c03but015.jpg onClick=printView()>";
        var newWindow = window.open();
        newWindow.document.open("text/html");  
        newWindow.document.write(print);  
        newWindow.document.close();    
   } 
</script>
//这里的图片替换成你的打印图片路径
<input type=image id=printView name=Button src=images/c03but015.jpg onClick=printView()>

//将要打印的东西放到这个标记内
<span id='print'> </span>

 

这个打印时打印控件实现的,会受浏览器的阻拦,使用的时候需要调整下ie的安全性。

IE属性,安全,Active活动的3个选项全部点启用

<a href="javascript:printme()" target="_self">
         <img src="../images/but2.gif" border="0" /></a>

posted on 2009-08-14 10:40  马英超  阅读(770)  评论(0编辑  收藏  举报