/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: onbeforeprint

[this page | pdf | back links]

The HTML onbeforeprint attribute specifies the event that is triggered before a document is printed. It applies to <body> elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body onbeforeprint="myOnbeforeprint()">
onbeforeprint: try printing page<br>

<script>
function myOnbeforeprint() {alert("Page about to be printed");}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile