我使用此代码实现按钮全屏,它工作正常。 我搜索相反的做法,我该怎么做? 感谢您的帮助。
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(&#34;全屏&#34;);
// 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
}
});
答案 0 :(得分:4)
您可以使用此功能:
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();
}
}
答案 1 :(得分:0)
答案适用于我的例子。
// 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
}
});
// Event listener for the full-screen button
normalScreenButton.addEventListener("click", function()
{
if(document.exitFullscreen)
{
document.exitFullscreen();
}
else if(document.mozCancelFullScreen)
{
document.mozCancelFullScreen();
}
else if(document.webkitExitFullscreen)
{
document.webkitExitFullscreen();
}
});