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?
According to the last comment 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 command :
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.