[whatwg] Should <video controls> generate click events?

Silvia Pfeiffer silviapfeiffer1 at gmail.com
Wed Aug 21 05:13:53 PDT 2013

On Wed, Aug 21, 2013 at 8:59 PM, Simon Pieters <simonp at opera.com> wrote:

> The problem was this: if you want to do something when a user clicks on a
> video but not when the user interacts with the native controls, you're
> basically out of luck.

No, you can do as you do below: you can define an onclick handler and do
something. As long as you don't do something that the native controls are
already taking care of, such as play() and pause(). If you are indeed
trying to influence the play/pause state of the video element both from
script and native controls, you need to be more creative with your event
handlers and use onclick and onpause and onplay event handlers and
carefully manage which ones cancel out which other ones.

<video controls onclick="if (paused) play(); else pause()"
> src=foobar></video>
> If the user clicks on the video's rendering area (i.e. outside the
> controls), this works as intended. However, if the user clicks on the
> native play/pause button, the video plays and then immediately pauses
> again. The change fixes this.

It also means that in the case of Firefox or in the case of Android Chrome,
where the native controls cover the full video with a overlay button when
not on autoplay, you cannot get any onclick events on the video element at


More information about the whatwg mailing list