Method for printing a specified area on the. net page

Source: Internet
Author: User

Use CSS to define a. noprint class and put non-printed content into this class.
The details are as follows:
Copy codeThe Code is as follows:
<Style media = print type = "text/css">
. Noprint {visibility: hidden}
</Style>
The content to print. Haha!
<P class = "noprint"> put the unprinted code here. </P>
<A href = "distinct Cr partition pt: window. print ()" target = "_ self"> print </a>

Method 2: Specify the print area
Put the content to be printed into a span or div and print it using a function.
Copy codeThe Code is as follows:
<Span id = 'div1 '> put the content to be printed here </span>
<P> all content </p>
<Div id = "div2"> div2 content </div>
<A href = "CR reset pt: printme ()" target = "_ self"> Print </a>
<Scr limit pt language = "Limit Cr limit pt">
Function printme ()
{
Document. body. innerHTML = document. getElementById ('div1 '). innerHTML +' <br/> '+ document. getElementById ('div2'). innerHTML;
Window. print ();
}
</Scr platinum pt>

If you want to print only a small part of the page, you 'd better use the second method.
Method 3: If the layout of the page to be printed is very different from that of the original web page, use this method.
Click the print button to bring up a new window, display the content to be printed to the new window, call the window. print () method in the new window, and then close the new window automatically.

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.