Sunday, 21 August 2016

JavaScript browser and media element events

HTML browser events


Event
Description
onafterprint
Fired after printing a document
onbeforeprint
Fired before printing a document
onbeforeonload
Fired before loading a document
Onblur
Fired when a window loses focus
onerror
Fired when an error occurs
onfocus
Fired when a window gets focus
onhaschange
Fired at the time of changing a document
onload
Fired at the time of loading a document
onmessage
Fired when the postMessage() method sends a message to the current document
onoffline
Fired when a document goes offline
ononline
Fired when a document gets online
onpagehide
Fired when a window is hidden
onpageshow
Fired when a window is visible
onpopstate
Fired when the history of a window changes
Onredo
Fired at the time of performing the redo action in the document
onresize
Fired at the time of resizing a window
onstorage
Fired when a document loads
onundo
Fired at the time of performing undo action in a document
onunload
Fired at the time of leaving a document

Example 1: onload event

<!DOCTYPE html>
<html>
<head>
    <title>onload Event</title>
    <script>
        function onload_event() {
            alert('display of alert box on page load');
        }
    </script>
</head>
<body onload="onload_event();">
    <h1>onload Event</h1>
</body>
</html>


HTML media element events

Event
Description
onabort
Fired on aborting a process
oncanplay
Fired when an audio or video file starts, but might has to stop for buffering
oncanplaythrough
Fired when an audio or video file is played to the end without buffering
ondurationchange
Fired on changing the length of the audio or video file
onemptied
Fired when a media element becomes empty due to some errors
onended
Fired when the media files end
onerror
Fired when an error occurs on loading an element
onloadeddata
Fired on loading the media file
onloadedmetadata
Fired on loading a media data, such as duration and size
onloadstart
Fired when a browser starts loading the media file
onpause
Fired on pausing the media file
Onplay
Fired when a media file is going to play
onplaying
Fired when media file plays
onprogress
Fired when a web browser retrieves the data of a media file
onratechange
Fired when the rate of playing the media file has changed
onreadystatechange
Fired on changing the ready state of the media file
onseeked
Fired when the seeking is completed. Seeking means moving media forward or backward
onseeking
Fired when the seeking process begin
onstalled
Fired when an error occurs while retrieving the media data
onsuspended
Fired when data retrieved is interrupted or suspended
ontimeupdate
Fired on changing the playing position of the media file
onvolumechange
Fired on changing the volume
onwaiting
Fired when the media file has stopped, but is expected to resume later

0 comments:

Post a Comment