小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

js的頁面打印,頁眉和頁腳一些多余信息怎么去除 Web 開發(fā) / JavaScript...

 gisinfowebis 2007-03-20
解決方案一:  
  <HTML><HEAD>  
  <script   language="JavaScript">  
  var   hkey_root,hkey_path,hkey_key  
  hkey_root="HKEY_CURRENT_USER"  
  hkey_path="\\Software\\Microsoft\\Internet   Explorer\\PageSetup\\"  
  //設(shè)置網(wǎng)頁打印的頁眉頁腳為空  
  function   pagesetup_null()  
  {  
      try{  
          var   RegWsh   =   new   ActiveXObject("WScript.Shell")  
          hkey_key="header"          
          RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")  
          hkey_key="footer"  
          RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")  
      }catch(e){}  
  }  
  //設(shè)置網(wǎng)頁打印的頁眉頁腳為默認(rèn)值  
  function   pagesetup_default()  
  {  
      try{  
          var   RegWsh   =   new   ActiveXObject("WScript.Shell")  
          hkey_key="header"          
          RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b頁碼,&p/&P")  
          hkey_key="footer"  
          RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d")  
      }catch(e){}  
  }  
  </script>  
  </HEAD>  
   
  <BODY><br/><br/><br/><br/><br/><br/><p   align=center>  
  <input   type="button"   value="清空頁碼"   onclick=pagesetup_null()>  
  <input   type="button"   value="恢復(fù)頁碼"   onclick=pagesetup_default()><br/>  
  </p></BODY></HTML>  
  需要將ie安全級(jí)別降低,否則創(chuàng)建ActiveXObject對(duì)象時(shí)會(huì)報(bào)錯(cuò)。  
  解決方案二:  
  使用第三方免費(fèi)控件  
  <head>  
  <title>打印確認(rèn)</title>  
  <style   media="print">  
  .noprint   {   display:   none   }  
  </style>  
  </head>  
  <body>  
  <object   id="factory"   style="display:none"   viewastext   classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"   codebase="http://www./scriptx/ScriptX.cab#Version=5,60,0,360"></object>  
  <script   defer>  
  function   window.onload()   {  
      //factory.printing.paperSize   =   "A3"  
      factory.printing.header   =   ""  
      factory.printing.footer   =   ""  
      factory.printing.portrait   =   false  
      idPrint1.disabled   =   false;   //   enable   UI   button  
      idPrint2.disabled   =   false;  
      idPrint3.disabled   =   false;  
      idPrint4.disabled   =   false;  
      factory.printing.leftMargin   =   0.75  
      factory.printing.topMargin   =   1.5  
      factory.printing.rightMargin   =   0.75  
      factory.printing.bottomMargin   =   1.5  
      }  
  </script>  
  <div   class=noprint>  
      <input   id="idPrint1"   type="button"   value="打印本頁"  
    onclick="factory.printing.Print(false)">  
      <input   id="idPrint2"   type="button"   value="頁面設(shè)置"  
    onclick="factory.printing.PageSetup()">  
      <input   id="idPrint3"   type="button"   value="打印預(yù)覽"  
    onclick="factory.printing.Preview()">  
      <input   id="idPrint4"   type="button"  
    onclick="window.close()"   value="關(guān)閉窗口">  
  </div>  
  <br/>  
  <table   width="720"   border="0"   cellspacing="0"   cellpadding="0"   align="center"   >  
      <tr>    
          <td     bgcolor="#0099ff">  
        這里是你要打印的內(nèi)容,上面的按鈕不會(huì)被打印出來<br/>  
        factory.printing.paperSize   =   "A3"  
        </td>  
  </tr></table></body>  
  要降低ie的安全級(jí)別。  
   
  兩種方案的缺點(diǎn)都是要降低ie的安全級(jí)別,如果不想降低,就不能在代碼中實(shí)現(xiàn),而要象上面一樣手動(dòng)更改了。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多