表單打印功能


表單打印的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