【问题标题】:How to open a current window in Full Screen Mode on button click in IE8如何在 IE8 中单击按钮时以全屏模式打开当前窗口
【发布时间】:2012-11-19 20:25:14
【问题描述】:

我在我的 MVC 代码中应用了一个 jquery 函数,以便在单击按钮时以全屏模式显示我的当前窗口。这是它的jquery:-

function FullScreen() {
    if ((document.fullScreenElement && document.fullScreenElement !== null) || // alternative standard method
    (!document.mozFullScreen && !document.webkitIsFullScreen)) { // current working methods
        if (document.documentElement.requestFullScreen) {
            document.documentElement.requestFullScreen();
        } else if (document.documentElement.mozRequestFullScreen) {
            document.documentElement.mozRequestFullScreen();
        } else if (document.documentElement.webkitRequestFullScreen) {
            document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
        }
    } else {
        if (document.cancelFullScreen) {
            document.cancelFullScreen();
        } else if (document.mozCancelFullScreen) {
            document.mozCancelFullScreen();
        } else if (document.webkitCancelFullScreen) {
            document.webkitCancelFullScreen();
        }
    }
}

我已经在标签的 onclick 事件中调用了这个函数。 有了这个,我可以在 Chrome 和 Mozilla 上以全屏模式点击按钮打开我的窗口,也可以在按下 ESC 键时退出全屏模式。但是在 IE8 中,当我单击按钮时,什么也没有发生。我怎样才能使这个功能适用于 IE8。 有什么建议吗?

谢谢。

【问题讨论】:

    标签: jquery asp.net-mvc-2 internet-explorer-8 fullscreen


    【解决方案1】:

    如果浏览器支持全屏 API(Chrome、FX10、Safari 6、Opera 12.1),那么您可以使用它。

    如果不是(例如 IE8),那么出于安全原因,您不应该模仿它:如果我可以创建一个全屏运行的页面而不先通知用户,那么我可以模仿操作系统界面元素询问密码等。

    这是how a phishing scam might work的一个很好的例子。

    这个安全原因是 WebKit 实现禁用键盘输入的原因。

    IE 曾经支持无铬弹出窗口,但这是removed as a security bug in IE6

    例如,您可以尝试发送 F11 键:

    var shell = new ActiveXObject("WScript.Shell");
    shell.SendKeys("{F11}");
    

    但这不应该在互联网环境中得到允许(它可能在受信任的域中,具体取决于用户设置)。

    IE10 无论如何都会全屏运行(默认情况下),因此仍然不支持此 API。

    【讨论】:

      【解决方案2】:

      抱歉,IE8 还不支持全屏 API。 Here 是一篇关于使用全屏 API 的好文章。它还指出 Internet Explorer 不支持全屏 API。

      Internet Explorer 或 Opera 尚不支持,但我会 建议您使用“ms”和“o”前缀以备将来校对。

      【讨论】:

      • 我不同意——通过猜测未来的前缀来“未来证明”是个坏主意,因为你不会知道实现的细节。
      猜你喜欢
      • 2021-03-28
      • 2012-05-24
      • 1970-01-01
      • 1970-01-01
      • 2019-10-07
      • 2012-08-31
      • 2018-10-01
      • 2023-03-14
      • 2017-10-13
      相关资源
      最近更新 更多