HTML event attribute onafterprint

The onafterprint attribute event is triggered when a page has started printing, or if the print dialogbox has been closed.

What's new in HTML5

The onafterprint attribute is new in HTML5.


<element onafterprint="script or javascript function name">

Supported Tags


Browser compatibility

onafterprint No Yes Yes No No


<!DOCTYPE html>
<body onafterprint="myFunction()">
<!-- w ww.ja  v  a  2  s.c  om-->
<h1>print this document</h1>

function myFunction() {


Click to view the demo