Zccst
1,css
<href= "/style/print.css" rel= "stylesheet" type = "Text/css" media= "print">
/STYLE/PRINT.CSS file
- . 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 ();
---------------------------------------------------------------