First method: Specify no area to print
Using CSS, define a. Noprint class, which will not be printed into this class.
Detail as follows:
<style media=print type= "Text/css" >
Noprint{visibility:hidden}
</style>
The content to be printed. Ha ha.
<p class= "noprint" > will not print the code here. </p>
<a href= "Javascript:window.print ()" target= "_self" > Printing </a>
Second method: Specify the print Area
Put the content you want to print into a span or div and print it through a function.
<span id= ' Div1 ' > Place the content to be printed </span>
<p> all content </p>
<div id= "Div2" >div2 div>
<a href= "Javascript:printme ()" target= "_self" > Print </a>
<script language= "JavaScript" >
function printme ()
{ document.body.innerhtml=document.getelementbyidx_x_x (' Div1 '). innerhtml+ ' <br/> ' +document.getelementbyidx_x_x (' Div2 '). InnerHTML;
Window.print ();
}
</script>
If you want to print only a small portion of the entire page, it's best to use the second method.
The Third way: if you want to print page layout and the original Web page is very different, this approach. The dot Print button pops up a new window, displays the content you want to print to a new window, calls the Window.print () method in a new window, and then automatically closes the new window.
Window.print can print Web pages, but sometimes we just want to print specific controls or content.
First we can put the content to be printed in the Div, and then use the following code to print.
Reproduced from: http://blog.sina.com.cn/s/blog_4696b3760100n58i.html