I have a page Print page where users can print cryptograms.

There are a lot of controls on the page which I really don't want to show up when the page is printed but are necessary to format the page prior to printing.
There is a simple solution using jQuery:
I wrap the controls in divs with id's of bottombuttons and pb and then add a handler for clicking the print button.
Here is the handler for the Print Button:
2 toggleButtons("No");
3 window.print();
4 toggleButtons("Yes");
5 return false;
6 })
2 if(on=="Yes"){
3 $("#botombuttons").show();
4 $("#pb").show();
5 }
6 else{
7 $("#botombuttons").hide();
8 $("#pb").hide();
9 }
10 return true;
11}
The result is that the controls disappear, then the window is printed and the controls restored.
#1 by freelance web developer on 9/14/09 - 4:15 PM
#2 by Don Vawter on 9/14/09 - 4:45 PM
#3 by freelance web developer on 9/14/09 - 5:08 PM
Your javascript solution requires the user to click your specific Print button.
All you need to do is assign a class to elements you want hidden. Like class='noPrint'.
Then in your print-only css:
.noPrint { display:none; }
Expanding that method, you can make print-only page headers with class="noScreen".
print-only css: .noScreen {display: ;}
screen-only css: .noScreen {display:none;}
Example:
http://www.harmonicdrive.net/products/gearheads/
#4 by Don Vawter on 9/14/09 - 5:29 PM
#5 by SALAMANDER on 12/8/09 - 12:09 AM
#6 by Don Vawter on 12/8/09 - 6:59 AM