Print page related

Source: Internet
Author: User

Zccst

1,css

<href= "/style/print.css"  rel= "stylesheet"  type  = "Text/css"  media= "print">

/STYLE/PRINT.CSS file

    1. . Noprint{display:none;}


In the testprint.html use the style in the Print.css, in the Web browsing time is not see the effect, but the printing will work, such as the following paragraph, plus noprint, in the browser is still realistic, but the printing time does not show:

< Div class="noprint">

< input type="button" onclick="Window.print ();" Value="Print this page" />

</ Div >


of course print.css inside the style you can write casually, change color AH (color image in black and white printer effect is not good, can be printed with another style), fonts or anything can, casually play ----

2,javascript

<script type= "Text/javascript" >$(function(){    //automatically executes before printingWindow.onbeforeprint =function(){        varHeight_left = $ (". W-desc1"). Height (); varHeight_right = $ (". W-DESC2"). Height (); if(Height_left >=height_right) {            $(". W-desc2"). Height (height_left); }Else if(Height_left <height_right) {            $(". W-desc1"). Height (height_right); }    }    //automatically executes after printingWindow.onafterprint =function(){        //$ ("#test"). Show ();    }});</script>

Before you print, you call the Window.onbeforeprint function, and you can use your ingenuity to reconstruct one side of the HTML and print it. Of course, after printing the general will get back, is the Window.onafterprint function

---------------------------------------------------------------

Tip: Note that printing we all know is window.print (), in fact, can also print frames, such as window.top.centerFrame.MainFrame.print ();  

---------------------------------------------------------------

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.