1. Use the CSS of "Media =" Print "to control the styling of the file to printed in TESTPRINT.HTML.
Copy code code as follows:
<link href = "/style/print.css" rel = "styleSheet" type = "text/css" media = "print">>
/style/print.css file
Copy code code as follows:
.noprint {display: none;}
Use the style in the print.css in testprint.html. When browsing the webpage, it does not see the effect, but it will work when printing. As in the following paragraph, after adding Noprint, it is still reality in the browser. Yes, but it is not displayed when printing:
Copy code code as follows:
<div>
<input type = "Button" onClick = "Window.print ();" Value = "Print this page" />
</div>
Of course, you can write in the style in Print.css, and change the color (color images are not good under black and white printers, you can print in another style), fonts can be played, just play ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------ -----------
2. Use JavaScript to control
Because of this, some people may not be proficient in CSS, some people JavaScript are more cattle X. Sometimes JavaScript is also a good choice
Copy code code as follows:
<script type = "text/javascript">
<!--
// Automatically execute before printing
Window.onbeForeprint = Function () {
$ ("#test"). Hide ();
}
// Automatically execute after printing
Window.onaFTERPRINT = FUNCTION () {
$ ("#test"). Show ();
}
//->
</script>
<div ID = "test"> This text will not be printed out </div>
Before printing, you will call the Window.onbeForePrint function. At this time, you can play at will, re -construct one side with HTML with your intelligence and wisdom, and then print. Of course, it is generally necessary to get it back after printing, that is, Window.OnafterPrint function
------------------------------------------------ ----------------
Tips: Pay attention, we all know that it is window.print (), in fact, you can also print the framework, such as window.top.centerframe.mainframe.print ();;