Internet Explorer 11不能通过Fullscreen API进入全屏模式。

7

我正在尝试使用全屏API。API在所有其他浏览器中都可以正常工作,但不幸的是IE11没有反应。我正在使用从这里复制的代码:

var element = $doc.documentElement;
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;

    if (requestMethod) 
    { // Native full screen.
        console.log(requestMethod);
        requestMethod.call(element);
    } 
    else if (requestMethod !== "undefined") 
    { // Older IE.
        console.log("window.ActiveXObject !== undefined");
        var wscript = new ActiveXObject("Wscript.shell");
        wscript.SendKeys("{F11}"); 
    }

有什么建议吗?

1
一个笔误吗?msRequestFullscreen - Yury Tarabanko
@YuryTarabanko 看不到它。 - TarikGuren
算了吧,我没意识到IE使用“Fullscreen”而不是FullScreen - Yury Tarabanko
规范建议“全屏”(https://fullscreen.spec.whatwg.org/#api),因此微软在这里似乎做得很对。 - Sampson
1个回答

4

请确保您没有使用无效的msRequestFullScreen方法,您需要使用大小写正确的版本msRequestFullscreen。这是微软特有的,因为我认为所有其他供应商都将单词"screen"中的s大写。


就像ftw一样,document.getElementById("myelem").msRequestFullscreen()被执行了,返回undefined,但在IE11上没有进入全屏模式... - Starwave

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接