I know the following methods for web printing: JQuery plug-in Jqprint implementation; JQery printing plug-in PrintArea for web page printing; CSS controls the web page printing style. This article describes the implementation steps in detail, if you are interested, you can learn about the wed printing method. What I know is:
1. JQuery plug-in Jqprint implementation
2. JQery printing plug-in PrintArea for web page Printing
3. CSS controls the webpage printing Style
JQuery plug-in Jqprint implementation:
First, import the js file:
Download jquery. jqprint. js
The Code is as follows:
Script
Script
Html code:
The Code is as follows:
This is displayed during printing.
This is hidden during printing.
Javascript code:
The Code is as follows:
$ (Document). ready (function (){
$ ("# Print"). click (function (){
$ (". My_show"). jqprint ();
})
});
Script
The plug-in also provides some configurable parameters,
The Code is as follows:
{
Debug: false, // if it is true, the iframe display effect can be displayed (iframe defaults to very small height and width, and can be adjusted in the source code). The default value is false.
ImportCSS: true, // true indicates that the css of the original page is imported. The default value is true. (If it is true, $ ("link [media = print]") is first found. If it is not true, the css file in $ ("link") is not found)
PrintContainer: true, // indicates that if the selected object must be included in the print (Note: setting it to false may break your CSS rules ).
OperaSupport: true // indicates that if the plug-in must also support the operabrowser, it provides a temporary print tab. The default value is true.
}
I only use importCSS: the link on the original page will be imported to iframe. For the first time, the media searchs = print. If not, the normal css file will be imported.
ImportCSS example:
The Code is as follows:
$ ('. My_show'). jqprint ({
ImportCSS: // CSS Style File
});