...

View Full Version : Hiding Print button on the printed hardcopy



florida
01-02-2003, 09:02 PM
Anyway to hide a button such as a "Print" button when the page has been printed to hardcopy? I have a Print button on my HTML page for printing but I dont want the Print button to show up on the printed hardcopy output.

Please advise how I can do this with what I have below:


function myprintfunction()
{
window.print();
}

<form>
<input type="button" value="Print" onClick="myprintfunction();">
</form>

scroots
01-02-2003, 11:06 PM
in one browser you can use the onprint function or method.

scroots

Steven_Smith
01-02-2003, 11:28 PM
<script>

ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;
function myprintfunction(id) {
if (ns4) document.layers[id].visibility = "hide"
else if (ie4) document.all[id].style.visibility = "hidden"
window.print();
}
</script>


<DIV ID="xxx" STYLE="position:relative;">

<input type="button" value="Print" onClick="myprintfunction('xxx');">

</DIV>

Try putting the button in a layer then hide the layer? Might work.

Steven

beetle
01-02-2003, 11:48 PM
You can use CSS for this
<style type="text/css">
@media print {
input#printButton {
display: none;
}
}
</style>

<input type="button" id="printButton" onclick="window.print();" value="Print Page" />

florida
01-03-2003, 01:31 PM
These all work in IE but the button still shows up in my Netscape 4 browser printout.

Please advise

beetle
01-03-2003, 02:14 PM
Don't expect to get NS4 to do a lot of what you want it to.

It is 5 years old, after all.

miranda
01-04-2003, 01:28 AM
what if you want to hide an image on the same page? I use the css code to hide the print button but there are two image files i wanted to hide. wgat I did was added a class called images and an id called images to each img tag and then added this class to the stylesheet to hide but to no avail. Any ideas what i did wrong?

<style type="text/css">
@media print {
input#print {
display: none;
}
img#images {
display: none;
}
}
</style>

beetle
01-04-2003, 01:59 AM
You used an ID selected when you need a class selector.

img.images {
display: none;
}

The # denotes an ID selector, the . denotes a class selector



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum