JS Printing Method Summary

Source: Internet
Author: User

 A time ago to do Web projects with the page to print, find some information on the internet, they have tried a lot of methods, these programs listed below:

1.window.print () method printing, all major browsers support the print () method

This method is very useful, only need to call the method can be printed, but this is the entire HTML printing, to print local words, to do otherwise.

2. Want to local printing, through the jquery plug-in can be achieved, now there are many such plugins online, such as Jqprint plug-ins and so on, can be very convenient to print a div, and will not affect the other. IE and Google are no problem, others have not been carefully measured.

3. If you want to print locally, you can also pass a pre-print and post-print event Onbeforeprint, Onafterprint. You can re-edit some formats before printing, specifically sent to print, printed and processed back. This is support IE and Firefox

function Window.onbeforeprint ()

{//Add some hidden} that do not need to be printed

function Window.onafterprint ()

{//Let go of hidden elements}

4. To the browser to install a print plug-in, such as Lodop plug-in, this is very easy to use, set dozen, local printing are all the leverage, but charges, free containing watermarks, compared to egg pain.

5. If you just need IE to print, you can directly through the JS call IE built-in WebBrowser printing components to complete the Web printing, support direct printing, Print preview, page setup, etc.

Summary: If you want to achieve a set dozen words, the proposed browser plug-in, if not too troublesome, you can pass the scheme 5, the print area for some of the precise control of the style, as well as the page settings, can also achieve the set dozen. In fact, the principle of local printing is that you do not want to print the part of the hidden, you want to print the part of the display, to achieve partial printing.

The above is their own summary of the printing method, if there is insufficient place! Please leave a message! Discuss learning with each other!

JS Printing Method Summary

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.