HTML - attributes - onafterprint

revision:


Content

syntax some examples

"onafterprint" attribute : printing started or printing dialogue closed

top

This attribute fires when a page has started printing, or if the print dialogue box has been closed. Tip: The onafterprint attribute is often used together with the onbeforeprint attribute.

Supported HTML tag:<body>


syntax

top

<element onafterprint="script"></element>

script: the script to be run on onafterprint


some examples

top

Try to print this document

Tip: Keyboard shortcuts, such as Ctrl+P sets the page to print.

codes
                    <body onafterprint="myFunction()">
                    <h3>Try to print this document</h3>
                    <p class="spec">Tip: Keyboard shortcuts, such as Ctrl+P sets the page to print.</p>
                    <script>
                        function myFunction() {
                        alert("This document is now being printed");
                        }
                    </script>