Introduction to various methods for implementing web printing and implementation of code _ javascript skills

Source: Internet
Author: User
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
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.