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