HTML - attributes - ona...

revision:


Content

"onabort" attribute : defines script for when loading aborts "onafterprint" attribute : printing started or printing dialogue closed

"onabort" attribute : defines script for when loading aborts

top

The onabort attribute defines a script to be run if the loading of the media file aborts.

This event occurs when the media data download has been aborted, and not because of an error.

The onabort attribute is part of the event attributes, and can be used on the following elements: <audio>, <embed>, <img>, <object>, <video>.

Events that occur when some disruption comes in the media loading process, are: onemptied, onerror, onstalled, onsuspend

syntax

<audio onabort="myScript"></ >

<embed onabort="myScript"></ >

<img onabort="myScript"></ >

<object onabort="myScript"></ >

<video onabort="myScript "></ >

some examples

example

HTML codes:

                <video style="margin-left:5vw;" id="myVideo" width="320" height="176" 
                    controls onabort="alert('Video load aborted')">
                        <source src="Wuzhen-20-10_02.mp4" type="video/mp4">
                    </video>
                

"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

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

script: the script to be run on onafterprint

some examples

example

Try to print this document

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

HTML 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>