<html>
<head>
<script type="text/javascript">
function printpage()
{document. getElementById ('print').style.display='none';
window.print()
}
</script>
</head>
<body>
<td align="center">
<input name="print" type="submit" id="print" value="PRINT" onclick="printpage()" />
</td>
</body>
</html>
When I click, it will open a print window.
Once I close print window and open it again and then click on print, without reloading, then it will not work.
Remove
document.getElementById('print').style.display='none';from yourprintpage()function.In the above case the button will be visible for another click event but when you will print the document, the button will be shown on printed document. Am I right?
To prevent printing the
printbutton you need to use css media queries@media printAdd following in your extrernal stylesheet OR in
<style>tag inside a<head>tag of the HTML page:and add
.noprintclass onSEE DEMO
It will print the document without printing the button and your button will also be visible for the second time click 🙂
EDITED:
USE HTML AS GIVEN BELOW:
SEE ABOVE CODE IN ACTION