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.