JS partial print

< Script  of the type = "text / JavaScript" > // / *********************** // / print designated area of the page // / Description: obj- or otherwise obtained by getElementById tag identification, in this print text obj @ / development: Wang Jian @ / date: 2009-8-7 function  startPrint (obj) { var  Owin = the window.open ( "" , " _blank " ); var  strPrint = " <style = H4 'font-size: 18px; text-align = left: Center;'> Print area preview </ H4> \ n- " ;     strPrint = strPrint  + " <script type=\"






ExpandedSubBlockStart.gif

    

    

    
 text/javascript\">\n";
    strPrint=strPrint + "function printWin()\n";
    strPrint
=strPrint + "{";
    strPrint
=strPrint +    "var oWin=window.open(\"\",\"_blank\");\n";
    strPrint
=strPrint + "oWin.document.write(document.getElementById(\"content\").innerHTML);\n";
    strPrint
=strPrint + "oWin.focus();\n";
    strPrint
=strPrint + "oWin.document.close();\n";
    strPrint
=strPrint + "oWin.print()\n";
    strPrint
=strPrint + "oWin.close()\n";
    strPrint
=strPrint + "}\n";
    strPrint
=strPrint + "<\/script>\n";
    
    strPrint
=strPrint + "<hr size=’1′ />\n";
    strPrint
=strPrint + "<div id=\"content\">\n";
    strPrint
=strPrint + obj.innerHTML + "\n";
    strPrint
=strPrint + "</div>\n";
    strPrint
=strPrint + "<hr size=’1′ />\n";
    strPrint
=strPrint + "<div style=’text-align:center’><button onclick=’printWin()’ style=’padding-left:4px;padding-right:4px;’>打  印</button>
<button onclick='window.opener=null;window.close();'  style='padding-left:4px;padding-right:4px;'>关  闭</button></div>\n";
    oWin.document.write(strPrint);
    oWin.focus();
    oWin.document.close();
}

</script>

<button id="btnPrint" onclick="startPrint(document.getElementById(’content’))">打印内容</button>
<div id= "Content" > < div  style = "font-size: 12px; Color: # 333;" >     This is the print content here is the print content here is the print content here is the print content here is the print content here is the print content here is a print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here within Print Here is the print content here is to print the contents of this print content here is to print the contents of this print content here is the print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here Print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is to print the contents of this print content here is the print content is printed here is to print the contents of this content is here to print content </ div > </ div >
    


    

Reproduced in: https: //www.cnblogs.com/zhangchenliang/archive/2009/12/25/1631771.html

Guess you like

Origin blog.csdn.net/weixin_33735676/article/details/93495979