window.open網頁打印頁頭頁尾爲空,支持瀏覽器IE8

//設置頁頭,頁尾爲空,調用PageSetup_Null();便可 var HKEY_Root,HKEY_Path,HKEY_Key;  HKEY_Root="HKEY_CURRENT_USER";  HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";  //設置網頁打印的頁眉頁腳爲空  function PageSetup_Null()  {  try  {  var Wsh=new ActiveXObject("WScript.Shell");  HKEY_Key="header";  Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");  HKEY_Key="footer";  Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");  }  catch(e)  {} } //例子:--------------------------------------------------------------------------------------- <html>  <head></head>  <style type="text/css" media="screen">  @media print{  .print {display:block;}  .notPrint {display:none;}  }  </style>  <script language="javascript">  function preview()  {  bdhtml=window.document.body.innerHTML;  sprnstr="<!--startprint-->";  eprnstr="<!--endprint-->";  prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);  prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));  window.document.body.innerHTML=prnhtml;  PageSetup_Null(); window.print();  } var HKEY_Root,HKEY_Path,HKEY_Key;  HKEY_Root="HKEY_CURRENT_USER";  HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";  //設置網頁打印的頁眉頁腳爲空  function PageSetup_Null()  {  try  {  var Wsh=new ActiveXObject("WScript.Shell");  HKEY_Key="header";  Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");  HKEY_Key="footer";  Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");  }  catch(e)  {} }  </script> <body>  <table id="datagrid">  <tr>  <td>網頁打印</td>  </tr>  </table>  <input class="Noprn" type="button" onclick="window.print()" value="網頁打印">  </form>  </body>  </html>
相關文章
相關標籤/搜索