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.

Syntax

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

Supported Tags

<body>

Browser compatibility

onafterprint No Yes Yes No No




Example

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

<script>
function myFunction() {
    alert("printed");
}
</script>

</body>
</html>

Click to view the demo