日期:2014-05-18 浏览次数:21041 次
<script language="javascript" type="text/javascript">
  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)
{ }
}
  function printpage(myDiv){ //DIV控制打印
    
  //var newstr = document.all.item(myDiv).innerHTML;  
  var newstr = document.getElementById(myDiv).innerHTML;
// alert(newstr);
  var oldstr = document.body.innerHTML;  
  document.body.innerHTML = newstr;  
  window.print();  
  document.body.innerHTML = oldstr;  
  return false;  
  }  
function preview() {
  PageSetup_Null();
  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;
  window.print();
}
    </script>
    <style>
        body
        {
            font-size: 16px;
            color: Black;
        }
    </style>
    <style media="print">
        .Noprint
        {
            display: none;
        }
        .PageNext
        {
            page-break-after: always;
        }
    </style>
------解决方案--------------------
好多帮助类,看自己需求拿相应方法。需要的多直接整个类拿来用,以后也方便
------解决方案--------------------
http://blog.csdn.net/happy09li/article/details/6931959