The onbeforeprint
attribute event is
triggered when a page is about to print or before the print dialogbox appears.
The onbeforeprint
attribute is new in HTML5.
<element onbeforeprint="script or javascript function name">
<body>
onbeforeprint |
Yes | Yes | Yes | Yes | Yes |
<!DOCTYPE html>
<html>
<body onbeforeprint="myFunction()">
<!--from w w w .j ava 2 s. c om-->
<h1>Try to print this document</h1>
<script>
function myFunction() {
alert("print");
}
</script>
</body>
</html>