js or jquery to implement page printing (partial printing) 1. js implementation (partial printing can be achieved) Copy code The code is as follows: js printing <br>.noprint{display : none } <br>< /style> <br><br><br><p class="noprint">Where printing is not required</p> <br><br><script> <br>function preview(oper) <br>{ <br>if (oper < 10) <BR>{ <BR>bdhtml=window.document.body.innerHTML;//Get the html code of the current page<BR>sprnstr="<!-- startprint" oper "-->";//Set the printing start area<br>eprnstr="<!--endprint" oper "-->";//Set the printing end area<br>prnhtml=bdhtml. substring(bdhtml.indexOf(sprnstr) 18); //Fetch html backward from the start code <br><br>prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); //Fetch forward from the end code html <br>window.document.body.innerHTML=prnhtml; <br>window.print(); <br>window.document.body.innerHTML=bdhtml; <br>} else { <br>window.print() ; <br>} <br>} <br></script> <br><p>XXXXX</p> <br><!--startprint1-->Content to print<!- -endprint1--> <br></body> <br></html> ) <BR></div><BR><BR><div class="codetitle">Copy code <span><a style="CURSOR: pointer" data="35839" class="copybut" id="copybut35839" onclick="doCopy('code35839')"><U> The code is as follows: </U></a> </span><HTML> </div><HEAD> <div class="codebody" id="code35839"><TITLE>javascript printing-print page settings-print preview code</TITLE> <br><META http-equiv=Content-Type content="text/html; charset=gb2312" /> <br><SCRIPT language=javascript> <br> Function printsetup(){ <br> // Print page setup <br> wb.execwb(8,1); <br>} <br> function printpreview(){ <br> // Print page preview <br> <br> wb.execwb(7,1); 'Are you sure you want to print? ')) { <br> wb.execwb(6,6); <br> } <br> } <br> </SCRIPT> <br></HEAD> <br><BODY> <br> <br><DIV align=center> <br><OBJECT id=wb height=0 width=0 <BR>classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb></OBJECT> <br><INPUT onclick=javascript:printit() type=button value=print name=button_print /> <br><INPUT onclick=javascript:printsetup(); type=button value=Print page setting name=button_setup /> <BR></BODY> <br></HTML> <br><br> <br>3. jQuery implementation (supports partial printing) <br><br><br><br><br>Copy Code<br><br><br> The code is as follows:<br><br> </div><html> <br><head> <br><script type="text/javascript" src="jquery -1.6.4.js"></script> <div class="codetitle"><script> <span>$(function(){ <a style="CURSOR: pointer" data="13812" class="copybut" id="copybut13812" onclick="doCopy('code13812')">$("input#biuuu_button").click(function(){ <u>$("div#myPrintArea").printArea(); </u>}); </a></script> </span></head> </div><body> <div class="codebody" id="code13812"><input id ="biuuu_button" type="button" value="Print"></input> <br><div id="myPrintArea">....Text printing part....</ div> <div class="quote_title">quote</div><div class="quote_div"></div> <br></body> <br></html> <br><br> </div>