I saw a script to do this the other day and didn't think I'd need it, but now I do.
I want to add a link after some output that the user will be printing, but I don't want the link/button to show up on the printout. Does anyone know how to do this?
Printable View
I saw a script to do this the other day and didn't think I'd need it, but now I do.
I want to add a link after some output that the user will be printing, but I don't want the link/button to show up on the printout. Does anyone know how to do this?
I can't think of how this script would work, but here's how you could do this:
make them use a print button on your page, not the file>>print button. Then when they press the button. hide a DIV which contains all the fields you want hidden and then print the page.
I think that's pretty much how it worked. Before it called the print function, it hid the button.
I guess my problem is that I don't know how to do that.
found it:
Code:<script language="JavaScript">
function printPage() {
if(document.all) {
document.all.divButtons.style.visibility = 'hidden';
window.print();
document.all.divButtons.style.visibility = 'visible';
} else {
document.getElementById('divButtons').style.visibility = 'hidden';
window.print();
document.getElementById('divButtons').style.visibility = 'visible';
}
}
</script>
<div id="divButtons" name="divButtons">
<input type="button" value = "Print" onclick="printPage()">
<input type="button" value = "Close" onclick="JavaScript:window.close();">
<hr noshade>
</div>
you could also specify a "print" CSS file that would hide the div....
At least that's how it is supposed to work... browser permitting....
Which means if it works in IE, it won't work anywhere else, and vice versa....
Haven't tried it though... yet... plan to some day.
TG
the script above does exatcly what I said.
but it only works in IE. Change all alls to getElementById()
eg
document.all.wee
to:
document.getElementById('wee')
that's in the else. :confused:
techgnome's stuff is in theory the best.
The nice thing is that it works even with a normal print command. The downside is IE.Code:<style type="text/css" media="print">
#printButton {
visibility: hidden;
}
</style>
You should have both. The IE solution in JS and the Mozilla/Opera etc. solution in CSS.
Since this is an in-house solution, I think I'll stick with the IE only version since that is all we use.