ใช้ ก่อนพิมพ์ เพื่อรันสคริปต์ก่อนพิมพ์เอกสารในรูปแบบ HTML
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้งาน onbeforeprint แอตทริบิวต์ −
<!DOCTYPE html>
<html>
<body onbeforeprint = "display()">
<script>
function display() {
alert("The document will now print.");
}
</script>
</body>
</html>