Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM onafterprint Event

  • Last Updated : 30 Jul, 2021

The DOM onafterprint event occurs when a web page has started printing or if the print dialogue box has been closed.
Supported Tags 

  • <body>


Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

  • HTML: 
<element onafterprint="myScript">
  • JavaScript: 
object.onafterprint = function(){myScript};
  • In JavaScript, using the addEventListener() method: 
object.addEventListener("afterprint", myScript);



<!DOCTYPE html>
        HTML | DOM onafterprint Event
        <h1 style="color:green">
        <h2>DOM onafterprint Event</h2>
            <strong>Tip: </strong>Keyboard
            shortcuts Ctrl+P
            window.addEventListener("afterprint", myGeeks);
            function myGeeks() {
                alert("Document Printed");


  • Before Print: 

  • After Print: 

Supported Browsers: The browsers supported by HTML DOM onafterprint Event are listed below: 

  • Google Chrome 63.0
  • Internet Explorer
  • Firefox


My Personal Notes arrow_drop_up
Recommended Articles
Page :