Run
Back to
HTML onbeforeprint Event Attribute
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>onbeforeprint event</title> </head> <body onbeforeprint="test()"> <h1>Try to print this document.</h1> <p><b>Tip:</b>The keyboard shortcut Ctrl + P prints the page.</p> <p><b>Note:</b>The onbeforeprint event is supported only in Internet Explorer and Firefox.</p> <script> function test() { alert("EXAMPLE: You are about to print this document!"); } </script> </body> </html>