gpt4 book ai didi

javascript - 在 Javascript 中实现与全屏相反的功能

转载 作者:行者123 更新时间:2023-11-30 09:48:49 26 4
gpt4 key购买 nike

我使用这段代码实现全屏按钮,效果很好。我想做相反的事情,我该怎么做?感谢您的帮助。

HTML

            <button type="button" id="full-screen" class="full-screen">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
<path d="M32 0h-13l5 5-6 6 3 3 6-6 5 5z"></path>
<path d="M32 32v-13l-5 5-6-6-3 3 6 6-5 5z"></path>
<path d="M0 32h13l-5-5 6-6-3-3-6 6-5-5z"></path>
<path d="M0 0v13l5-5 6 6 3-3-6-6 5-5z"></path>
</svg>
</button>

JavaScript var fullScreenButton = document.getElementById("全屏");

            // Event listener for the full-screen button
fullScreenButton.addEventListener("click", function()
{
if (player.requestFullscreen)
{
player.requestFullscreen();
}
else if (player.mozRequestFullScreen)
{
player.mozRequestFullScreen(); // Firefox
}
else if (player.webkitRequestFullscreen)
{
player.webkitRequestFullscreen(); // Chrome and Safari
}
});

最佳答案

你可以使用这个函数:

function exitFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}

关于javascript - 在 Javascript 中实现与全屏相反的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37545929/

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