Click to See Complete Forum and Search --> : Hiding print button on hardcopy output


florida
01-02-2003, 02:04 PM
Post Preview:
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>

Charles
01-02-2003, 02:26 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>
<style type="text/css" media="print">
<!--
.hide {display:none}
-->
</style>
</head>
<body>
<script type="text/javascript">
<!--
if (window.print) {
document.write('<form class="hide"><p><input type="submit" value="Print"></p></form>');
document.forms[document.forms.length-1].onsubmit = function () {window.print(); return false};
};
// -->
</script>
</body>
</head>

AdamBrill
01-02-2003, 02:29 PM
Try putting it inside a div tag and then hide the div until you want it to be shown. Everything that you put inside the div tags will be hidden. Then just make the div tag visible when you want to...