HTML DOM onafterprint Event
Last Updated :
20 Jun, 2023
The DOM onafterprint event occurs when a web page has started printing or if the print dialogue box has been closed.
Supported Tags:
Syntax:
<element onafterprint="myScript">
object.onafterprint = function(){myScript};
- In JavaScript, using the addEventListener() method:
object.addEventListener("afterprint", myScript);
Example: In this example, we will see the use of DOM onafterprint Event
HTML
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM onafterprint Event
</ title >
</ head >
< body >
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h2 >DOM onafterprint Event</ h2 >
< p >
< strong >Tip: </ strong >
Keyboard shortcuts Ctrl+P
</ p >
< script >
window.addEventListener("afterprint", myGeeks);
function myGeeks() {
alert("Document Printed");
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers: The browsers supported by HTML DOM onafterprint Event are listed below:
- Google Chrome 63.0
- Internet Explorer
- Firefox
Share your thoughts in the comments
Please Login to comment...