This article mainly introduces the choice of JS print content, mainly to print their own things with a div layer to hold up, need friends can refer to the following
Because the project needs to select the printed content in one page. Pick up what you want to print with a div layer. For example, the: code is as follows: <!--referral to the office to inform the--> <div id= "Itemvrbjform" style= "font-family: ' Imitation ', ' Arial '; Font-size: 18px; margin-top:290px, "> <div style=" width:600px; margin:0 auto; " > <div style= "float:right;margin-top: -40px;" > (Notification Order number: ${zjxfitemuser.acceptedno}) </div> <div id= "title" style= "margin-top:40px;" ><span > Petition Matters Forwarding notice </span></div> ${zjxfitemuser.username}: (Name of the complainant) <br/> <span id= "Itemvrbjtime" ></span>, the Agency (or unit) has accepted your (or your) proposed ${zjxfitemuser.subject} petition matters in accordance with the law , the matter under the terms of reference of XXX, according to the relevant provisions of the regulations on letters and visits, the authority has been in XXXX xx month XX days to transfer the relevant materials to XXX processing, please contact with the timely. <br/> hereby inform. <BR/> <div style= "margin-top:50px;margin-right:20px;float:right;" > (Cover ${zjxfprocessover.suborgname} special chapter or official seal) </div> <div style= "margin-top:90px;margin-right: -190px; Float:right; " ≫<span id= "Itemvrbjendtime" ></span></div> </div> </div> <!-- Petition matters transfer to the Office to inform the single end--> in the middle there is no need to print, but also with a div layer included. Using CSS styles in the. Reference class= "noprint" in layers that do not need to be printed the code is as follows: <style type= "text/css" media= "print" > . Noprint{visibility: none;} </style> JS code: NOTE: When you choose to print, the style will be lost, you need to print before printing. Code as follows: $ (function () { $ ("#print"). Click (function () { var html = window.document.body.innerhtml; EXPORTCSS ("Itemvrbjform", html); }); // Import style to select print function exportcss (formname,htmlinfo) { var CSS = "<link href=" "+ BaseURL +"/zjxf/common/css/ Common.css "type=" Text/css "rel=" stylesheet "/>" + "<link href=" "+ BaseURL +"/zjxf/common/css/table.css " Type= "Text/css" rel= "stylesheet"/> "+ " <link href= "" + BaseURL + "/zjxf/common/css/form.css" type= "text/css "Rel=" stylesheet "/>" + "<link href="" + BaseURL + "/zjxf/common/css/tab.css" type= "Text/css" rel= "stylesheet"/> "+ " <link href= "" + BaseURL + "/ Zjxf/common/css/print.css "type=" Text/css "rel=" stylesheet "/>"; $ (CSS). Appendto ("#" + formName); Window.document.body.innerHTML = $ ("#" + formName). HTML (); window.print (); Window.document.body.innerHTML = htmlinfo; } }); This enables both local and local-not-select printing