<html><head><script language="javascript">function printIt() { htmlcode=window.document.body.innerHTML; sprnstr="<!--startprint-->"; eprnstr="<!--endprint-->"; var prnhtml=htmlcode.substr(htmlcode.indexOf(sprnstr)+17); prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); window.document.body.innerHTML=prnhtml; window.print(); window.document.body.innerHTML=htmlcode;}</script></head>
<body>不想打印内容<br/><!--startprint-->要打印内容<!--endprint--><br/>不想打印内容<br/><a href="javascript:printIt()">打印</a></body></html>昨天刚找到的,原帖地址没有记住~~~
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT><script language="vbscript"> dim hkey_root,hkey_path,hkey_key hkey_root="HKEY_CURRENT_USER" hkey_path="/Software/Microsoft/Internet Explorer/PageSetup" Set RegWsh = CreateObject("WScript.Shell") hkey_key="/header" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"" hkey_key="/footer" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""</script>
<script language="javascript"> document.all.WebBrowser.ExecWB(6,6); window.close();</script>
1)ie的文件-〉页面设置-〉讲里面的页眉和页脚里面的东西都去掉,打印就不出来了.(2)<HTML><HEAD><TITLE> New Document </TITLE><META NAME="Generator" CONTENT="EditPlus"><META NAME="Author" CONTENT="YC"><script language="VBScript">dim hkey_root,hkey_path,hkey_keyhkey_root="HKEY_CURRENT_USER"hkey_path="/Software/Microsoft/Internet Explorer/PageSetup"'//设置网页打印的页眉页脚为空function pagesetup_null() on error resume next Set RegWsh = CreateObject("WScript.Shell") hkey_key="/header" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"" hkey_key="/footer" RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""end function'//设置网页打印的页眉页脚为默认值function pagesetup_default() on error resume next Set RegWsh = CreateObject("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"end function</script></HEAD>
<BODY><br/><br/><br/><br/><br/><br/><p align=center><input type="button" value="清空页码" οnclick=pagesetup_null()> <input type="button" value="恢复页吗" οnclick=pagesetup_default()><br/>
</p></BODY></HTML>
控制"纵打"、 横打”和“页面的边距。 (1)<script defer> function SetPrintSettings() { // -- advanced features factory.printing.SetMarginMeasure(2) // measure margins in inches factory.SetPageRange(false, 1, 3) // need pages from 1 to 3 factory.printing.printer = "HP DeskJet 870C" factory.printing.copies = 2 factory.printing.collate = true factory.printing.paperSize = "A4" factory.printing.paperSource = "Manual feed"
// -- basic features factory.printing.header = "This is MeadCo" factory.printing.footer = "Advanced Printing by scriptX" factory.printing.portrait = false factory.printing.leftMargin = 1.0 factory.printing.topMargin = 1.0 factory.printing.rightMargin = 1.0 factory.printing.bottomMargin = 1.0 } </script>
(2) <script language="javascript"> function printsetup(){ // 打印页面设置 wb.execwb(8,1); } function printpreview(){ // 打印页面预览 wb.execwb(7,1); }
function printit() { if (confirm(''确定打印吗?'')) { wb.execwb(6,6) } } </script> </head> <body> <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"
height=0 id=wb name=wb width=0></OBJECT> <input type=button name=button_print value="打印"
οnclick="javascript:printit()"> <input type=button name=button_setup value="打印页面设置"
οnclick="javascript:printsetup();"> <input type=button name=button_show value="打印预览"
οnclick="javascript:printpreview();"> <input type=button name=button_fh value="关闭"
οnclick="javascript:window.close();">
<script language="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){} } --></script><body bgcolor="#FFFFFF" text="#000000" οnlοad="PageSetup_Null()"><center class="Noprint" ><p><OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT><input type=button value=打印 οnclick=document.all.WebBrowser.ExecWB(6,1)><input type=button value=直接打印 οnclick=document.all.WebBrowser.ExecWB(6,6)><input type=button value=页面设置 οnclick=document.all.WebBrowser.ExecWB(8,1)><input type=button value=打印预览 οnclick=document.all.WebBrowser.ExecWB(7,1)></p><p> <input type=button value="导出成excel" onClick="return ExcelDown();"><hr align="center" width="90%" size="1" noshade></center><table width="560" align="center" cellpadding="3" cellspacing="1" class="18txt">……