Webmaster Resources Center

Welcome to the Bravenet Resource Center. Use these resources to help make your web pages more advanced and fun to use.

Articles & Tutorials

Disappearing Print Button

by Bravenet.com


Summary : Wouldn't it be nice to be able to put a "print page" button on your webpage without it showing up in the printed out page. Here is a little script that will do just that. The button appears on the webpage, but when the page is printed the button isn't on the printed page. Note: this script will only work with newer browser versions.

This code is simple and easy to use. First, start off by puting this script between the <head> and </head> tags of your webpage.

<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>

This part of the script can be placed anywhere within the body of your webpage where you would like the button to appear.

<div id="divButtons" name="divButtons">
<input type="button" value = "Print this page" onclick="printPage()" style="font:bold 11px verdana;color:#FF0000;background-color:#FFFFFF;">
</div>