【问题标题】:Fullscreen not working in IE全屏无法在 IE 中运行
【发布时间】:2023-12-02 22:38:01
【问题描述】:

所以我的滑块模块启动并运行,但 Internet Explorer 11 没有响应全屏按钮。 Firefox 和 Chrome 运行良好。我在 Stack 上找到了这段代码,但仍然没有区别。有什么想法吗?

function toggleFullScreen() {
  if (!document.fullscreenElement &&    // alternative standard method
      !document.mozFullScreenElement && !document.webkitFullscreenElement) {  // 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 (elem.msRequestFullscreen) {
            elem.msRequestFullscreen();
    }


  } else {
    if (document.cancelFullScreen) {
      document.cancelFullScreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.webkitCancelFullScreen) {
      document.webkitCancelFullScreen();
    } else if (document.msExitFullscreen) {
            document.msExitFullscreen();
        }
  }
}

 </script>

对不起,如果这个问题已经回答。我还没有找到解决办法。

【问题讨论】:

    标签: javascript jquery html responsive-design fullscreen


    【解决方案1】:

    根据site,IE 不支持全屏 API。似乎也没有关于这是否会被 IE11 支持的信息。

    根据 MDN 的 article on fullscreen 看来,这种技术对于大多数浏览器来说仍然是非常实验性的。

    你也可以试试这个

    Internet Explorer full screen mode?

    Set window to fullscreen (REAL fullscreen; F11 functionality) by javascript

    <script type="text/javascript">
        function max() {
            var wscript = new ActiveXObject("Wscript.shell");
            wscript.SendKeys("{F11}");
        }
    </script>
    

    如果你真的想在 Internet Explorer 中全屏显示......请尝试在 jquery 中将滑块宽度和高度设置为 100%。

    【讨论】:

    • @dnp76 没问题的朋友
    • 好吧,看来我错过了什么。只要滑块是自立式的,该功能就可以工作。不幸的是,客户在他们的 WP 页面的 iframe 中有滑块。所以现在当我们在 IE11 上点击 F11 时,WP 页面也会全屏显示。 Firefox 或 Chrome 并非如此。我肯定需要解决这个 iFrame 问题。
    • 移除 iframe。不再使用 iframe
    • 不确定是否有任何其他方法可以获取此 html 站点...alloytoy.rheinfelden-alloys.eu ...在此 wp 站点上显示... rheinfelden-alloys.eu 而不使用iframe 或小部件。
    • 你想获取另一个网页的html?你可以使用 jquery 来做到这一点
    最近更新 更多