Horje

How to Execute a JavaScript when a page has started printing, or if the print dialogue box has been closed

Try to print this document Tip: Keyboard shortcuts, such as Ctrl+P sets the page to print. Note: The onafterprint event is not supported in Safari and Opera. Note: In IE, the onafterprint event occurs before the print dialogue box, instead of after.
index.html
Example: HTML
<script>
function myFunction() {
  alert("This document is now being printed");
}
</script>

Output should be:

How to Execute a JavaScript when a page has started printing, or if the print dialogue box has been closed




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin