简体   繁体   English

在全屏模式Internet Explorer中检测事件更改

[英]Detecting Event change in fullscreen mode Internet explorer

I am trying to write an event handler that detects whether a video player I have is in fullscreen or 'regular' mode. 我正在尝试编写一个事件处理程序,用于检测我所拥有的视频播放器是处于全屏还是“常规”模式。

I have tried using 我试过用

 document.addEventListener("fullscreenchange", myfunc, false);

but this doesn't work in IE, I have implemnted the same thing for firefox and chrome using webkitfullscreenchange and mozfullscreenchange event. 但这在IE中不起作用,我使用webkitfullscreenchange和mozfullscreenchange事件为firefox和chrome实现了同样的功能。 Is there any other event I can use in IE for this? 我可以在IE中使用其他任何事件吗? Or another way of doing this? 或者另一种方式呢?

Any help would be appreciated. 任何帮助,将不胜感激。 Thanks! 谢谢!

You have jQuery, so use it: 你有jQuery,所以使用它:

var screen_change_events = "webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange";
$(document).on(screen_change_events, function () {

});

( addEventListener isn't supported in versions earlier than IE 9 anyways) (无论如何,IE 9之前的版本不支持addEventListener

At the same time, it doesn't look like full screen is supported in any version of IE: 同时,在任何版本的IE中都不支持全屏:

MDN Reference: MDN参考:

Here's a possible hack around it: 这是一个可能的黑客围绕它:

There is a jQuery plugin named jquery-fullscreen that will do exactly what you want. 有一个名为jquery-fullscreen的jQuery插件可以完全按照你的需要进行操作。 Until the Fullscreen-API standard has crystallized this is probably the best option. 在Fullscreen-API标准结晶之前,这可能是最好的选择。

You can also use the Modernizr fullscreen-api check and shim it if the browser doesn't support it by firing the event yourself (see this question for a detection method) 您也可以使用Modernizr fullscreen-api检查并在浏览器不支持的情况下通过自己触发事件来填充它(请参阅此问题以获取检测方法)

download this script: https://raw.githubusercontent.com/sindresorhus/screenfull.js/gh-pages/dist/screenfull.js 下载此脚本: https//raw.githubusercontent.com/sindresorhus/screenfull.js/gh-pages/dist/screenfull.js

use this code: 使用此代码:

if (screenfull.enabled) {
    screenfull.onchange(() => {
        icono_full(screenfull.isFullscreen);
    });
}


function icono_full(x) {
    if (x == true) {
        //do when full screen is on
    } else {
        //not full screen
    }
}

see: https://github.com/sindresorhus/screenfull.js 请参阅: https//github.com/sindresorhus/screenfull.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM