表单打印功能


表单打印的2种方式

一、支持不同的浏览器

1、表单打印功能调用window.print() 就可以打印了

2、如果只打印表单上的一部分样式,将不想打印的部分写在@media print中,隐藏掉

<style>
  @media print{
    .Noprint{
      display:none;
    }
  }
</style>

3、如果还想实现打印预览的话,如下写法:

  var newWin = "print";
  window.open("./11.html",newWin,'location=no,menubar=no,toolbar=no,status=no,directories=no,scrollbars=yes,resizable=yes,width=700 height=500');
  frmMain.target = newWin;
  frmMain.submit();

 我的理解是将当前表单重新提交到一个新的窗口上即可

 

二、只支持IE浏览器 

<style media="print">
        .Noprint
        {
            display: none;
        }
</style>
<center class="Noprint">
     <object id="WebBrowser" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" width="0"> </object>
     <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>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM