Code
Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy onbeforeprint attribute</title> </head> <body onbeforeprint="onBeforePrint()"> <h1>Wikitechy HTML onbeforeprint Attribute</h1> <h4>Try to print this page</h4> <p>Press Ctrl+P to print</p> <script> function onBeforePrint() { alert("About to print this document!"); } </script> </body> </html>
Result