The way to print the web I know it by myself:
1, jquery plug-in Jqprint implementation
2, jqery Print plug-in PrintArea to achieve web page printing
3, CSS control page print style
jquery plugin Jqprint Implementation:
First you want to import the JS file:
Jquery.jqprint.js Download
Copy Code code as follows:
<script language= "javascript" src= "Jquery-1.7.1.min.js" ></script>
<script language= "javascript" src= "Jquery.jqprint.js" ></script>html Code:
Copy Code code as follows:
<div class= "My_show" >
This print is displayed.
</div>
<div class= "My_hidden" >
This print is hidden.
</div>
<input type= "button" id= "Print"/>
JavaScript code:
Copy Code code as follows:
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("#print"). Click (function () {
$ (". My_show"). Jqprint ();
})
});
</script>
The plug-in also provides some parameters to configure:
debug:false,//If True, you can display the IFrame view effect (iframe default high and wide are very small, can be adjusted in the source code), the default is False
Importcss:true,//true represents the introduction of the original page CSS, the default is true. (If it is true, the $ ("Link[media=print]") is found first, if no will go to the CSS file in $ ("link")
printcontainer:true,//indicates that if the object originally selected must be printed (note: setting to false may break your CSS rules).
operasupport:true//says if the plugin must also support the Opera browser, in this case it provides a temporary print tab. The default is True
And I use only importcss: the links in the original page will be imported into the IFRAME. The first time it media searchs = print, if not, the normal CSS file will be imported.
Importcss Sample:
Copy Code code as follows:
$ ('. My_show '). Jqprint ({
Importcss://css Style File
});