gpt4 book ai didi

javascript - document.documentElement.msRequestFullscreen() 返回未定义

转载 作者:行者123 更新时间:2023-12-02 21:05:53 25 4
gpt4 key购买 nike

我正在尝试在 ie11 上使用 document.documentElement.msRequestFullscreen() 进入全屏。它返回未定义。

还有

var elem = document.getElementById("ember715"); 
elem.msRequestFullscreen()

在 ie11 上返回未定义。P.S- elem.requestFullscreen() 在 chrome 中完成这项工作,因此 elem 已正确定义。我借用了这个想法 How to enable IE full-screen feature like firefox and chrome

最佳答案

建议您使用下面的代码进行测试。我用 IE 11 测试了一下,效果很好。

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<h2>Fullscreen with JavaScript</h2>
<p>Click on the button to open the video in fullscreen mode.</p>
<button onclick="openFullscreen();">Open Video in Fullscreen Mode</button>
<p><strong>Tip:</strong> Press the "Esc" key to exit full screen.</p>

<video width="100%" controls id="myvideo">
<source src="https://www.w3schools.com/jsref/rain.mp4" type="video/mp4">
<source src="sample.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

<script>
/* Get the element you want displayed in fullscreen */
var elem = document.getElementById("myvideo");

/* Function to open fullscreen mode */
function openFullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.mozRequestFullScreen) { /* Firefox */
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE/Edge */
elem.msRequestFullscreen();
}
}
</script>

<p>Note: Internet Explorer 10 and earlier does not support fullscreen mode.</p>

</body>
</html>

引用:

HTML DOM requestFullscreen() Method

关于javascript - document.documentElement.msRequestFullscreen() 返回未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61229927/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com