最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Mozfullscreenchange event doesn't fire - Stack Overflow

programmeradmin2浏览0评论

My Code:

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

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

webkitfullscreenchange works as expected, but mozfullscreenchange seems to do nothing.

.bind doesn't help either.

What am I doing wrong?

My Code:

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

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

webkitfullscreenchange works as expected, but mozfullscreenchange seems to do nothing.

.bind doesn't help either.

What am I doing wrong?

Share Improve this question edited May 13, 2015 at 17:21 OneHoopyFrood 3,9793 gold badges27 silver badges39 bronze badges asked May 13, 2015 at 16:40 Allan Felipe MuraraAllan Felipe Murara 5263 silver badges14 bronze badges 2
  • 1 Could you provide some background on what your end goal is? – OneHoopyFrood Commented May 13, 2015 at 17:02
  • i need to know when user left fullscreen to validate input infos. – Allan Felipe Murara Commented May 13, 2015 at 17:17
Add a ment  | 

3 Answers 3

Reset to default 5

According to the last ment here:

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

They also say it is documented on mozilla developer pages.

So put the listener on a document, not on the element.

Thanks to simon, i forgot the moz documentation.

final mand :

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

Mobile Safari and Chrome needed this to detect the exit of fullscreen:

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

评论列表(0)

  1. 暂无评论