A number of projects need to achieve page printing, especially some background management system, the following introduction of a lightweight print plugin:
1, implement the page printing to introduce jquery and Jqprint. Click to download Jqprint plugin
<language= "javascript" src= "Jquery-1.4.4.min.js"> </script><language= "JavaScript" src= "Jquery.jqprint-0.3.js"></script>
2. HTML code:
<DivID= "Print-area"> <Table> <TR> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> </TR> <TR> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> </TR> <TR> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> </TR> <TR> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> </TR> <TR> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> <TD>Test</TD> </TR> </Table> </Div> <inputtype= "button"onclick= "Print ()"value= "Print">
3. JavaScript code:
<script language= "JavaScript" > function print () { $ ("#print-area"). Jqprint ({ false, true, true, false }); </script>
4. Properties
- Debug:false,//True to display the IFrame view effect (the IFRAME default height and width are very small, can be increased in the source code), the default is False
- Importcss:true,//true represents the introduction of the original page of the CSS, the default is true. (If True, you will find $ ("link[media=Print]"), if you do not find the CSS file in $ ("link" )
- Printcontainer:true,//indicates that if the original selected object must be included in the print (note: setting to false may break your CSS rules).
- Operasupport:false//indicates that if the plugin must also support the Opera browser, in this case it provides a temporary print tab. The default is True
5. Special print style
If you need a unique CSS style when printing, you can also write it directly within the style property by
<href= "Printstyle.css" reltype= "Text/css" Media= "print">
To reference the styles in an external CSS file. The benefit is that the style will only be applied when printing.
2.
1, 1.1, http://www.jq22.com/jquery-info3471.2, HTTPS://WWW.JB51.NET/ARTICLE/102230.HTM2,
|
Ylbtech Source: http://ylbtech.cnblogs.com/ This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility. |
Javascript-tool:jquery.jsprint.js