We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

GlobalEventHandlers.onplay

The GlobalEventHandlers.onplay property sets and returns the event handler for the play event that is fired when playback has begun.

Syntax :

element.onplay = handlerFunction;
var handlerFunction = element.onplay;

handlerFunction should be either null or a JavaScript function specifying the handler for the event.

Example :

<!DOCTYPE html>
<html>
<head>
<body>

<title>onplay event example :</title>

<p>This example demonstrates how to assign an "onplay" event to a video element.</p>

<video controls onplay="myFunction()">
  <source src="mov_bbb.mp4" type="video/mp4">
  <source src="mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>

<script>
function myFunction() {
    alert("The video has started to play");
}
</script>

</head>
</body>
</html>

Specification :

Specification Status Comment
HTML Living Standard
The definition of 'onplay' in that specification.
Living Standard

 

Browser compatibility :

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox Internet Explorer 9.0 Opera Safari
onplay yes yes yes yes yes

 

See also :

Information on working with event handlers

Document Tags and Contributors

Contributors to this page: Guillaume-Heras, rolfedh
Last updated by: Guillaume-Heras,