Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing option 1

Status
Not open for further replies.

sed10

Programmer
Feb 8, 2001
5
FR
Hello,
I would like to know if it's possible to print only an area of an internet screen, for exaple how to print a page without the "print" button
Thank you
 
You can use the code below for IE:

function printHandler()
{
document.styleSheets[0].addRule(".removeforprint", "display:none;");
}

function afterPrint()
{
document.styleSheets[0].addRule(".removeforprint", "display:inline;");
}
window.onafterprint = afterPrint
window.onbeforeprint = printHandler

Just add the class "removeforprint" to any element you want hidden when the page prints. jared@aauser.com -
 
It's strange; the solution you gave me has worked 2 times, then nothing. I put alerts in the 2 functions and in the screen it seems to be OK (even the buttons I wanted to hide are not visible) but, when we get the printed sheet they are in...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top