Mozfullscreenchange 事件不会触发

Mozfullscreenchange event doesn't fire

我的代码:

$('#divid').on('mozfullscreenchange webkitfullscreenchange fullscreenchange MSFullscreenChange', notify);

$('#divid').bind('mozfullscreenchange webkitfullscreenchange fullscreenchange MSFullscreenChange', notify);

webkitfullscreenchange 按预期工作,但 mozfullscreenchange 似乎什么也没做。

.bind 也无济于事。

我做错了什么?

根据最后一条评论here:

the event is fired at the document, not at the element that goes full-screen

他们还说它被记录在案 on mozilla developer pages

所以将侦听器放在 document 上,而不是元素上。

感谢 simon,我忘记了 moz 文档。

最终命令:

   document.addEventListener("fullscreenchange", notify);
   document.addEventListener("webkitfullscreenchange", notify);
   document.addEventListener("mozfullscreenchange", notify);
   document.addEventListener("MSFullscreenChange", notify);

Mobile Safari 和 Chrome 需要这个来检测全屏退出:

  video.addEventListener('webkitendfullscreen', function () {
    // do stuff here
  }, false);