onabort
onabort event
The onabort
event is triggered when the user cancels the loading of media (<audio>
or <video>
). This is different from the onerror
event, which deals with errors during loading. To use it, attach onabort
to a media element and define the JavaScript function to run when the event occurs.
Syntax
In HTML
<element onabort="myScript">
In JS
object.onabort = function(){myScript};
addEventListener()
function is used. In JavaScript, the
object.addEventListener("abort", myScript);
Values
<script>
- The function that should be executed when the event is triggered.
Conclusion
The onabort
event is triggered when media loading (<audio>
or <video>
) is canceled by the user. It is different from the onerror
event, which handles loading errors. By attaching onabort
to a media element, you can define a JavaScript function to execute when the event occurs.
Media
HTML media event attributes handle events related to media elements like audio and video, enabling control over playback, loading, and other media interactions.
oncanplay
The oncanplay event is triggered when the browser has buffered enough of the media to begin playback. It indicates that the media is ready to start playing.