exitFullscreen()方法請求將當前處於全屏模式的元素從全屏模式中取出。如果element不在全屏模式,則什麽都不會改變。此方法的反向是requestFullscreen()。
用法:
HTMLElementObject.exitFullscreen()
參數:無需參數。
返回值:沒有返回值。
例:
<!DOCTYPE html>
<html>
<head>
<title>
HTML | DOM exitFullscreen() Method
</title>
<!--script for close and open fullscreen-->
<script>
var elem = document.documentElement;
function closeFullscreen() {
if (document.exitFullscreen)
document.exitFullscreen();
}
function openFullscreen() {
if (elem.requestFullscreen)
elem.requestFullscreen();
}
</script>
</head>
<body>
<h2>Welcome to GeeksforGeeks</h2>
<p>
Click on the "Open Fullscreen" button to open this page in"
+ "fullscreen mode. Close it by either clicking the "Esc" key"
+" on your keyboard, or with the "Close Fullscreen" button.
</p>
<button onclick="openFullscreen();">
Open Fullscreen
</button>
<button onclick="closeFullscreen();">
Close Fullscreen
</button>
</body>
</html>
輸出:
全屏打開
退出全屏
支持的瀏覽器:下麵列出了DOM exitFullscreen()方法支持的瀏覽器:
- 穀歌瀏覽器
- IE瀏覽器
- 火狐瀏覽器
- Opera
- 蘋果瀏覽器
相關用法
- HTML DOM contains()用法及代碼示例
- HTML DOM getBoundingClientRect()用法及代碼示例
- HTML DOM execCommand()用法及代碼示例
- HTML DOM removeNamedItem()用法及代碼示例
- HTML DOM requestFullscreen()用法及代碼示例
- HTML DOM createDocumentFragment()用法及代碼示例
- HTML DOM removeEventListener()用法及代碼示例
- HTML DOM item()用法及代碼示例
- HTML DOM replaceChild()用法及代碼示例
- HTML DOM renameNode()用法及代碼示例
- HTML DOM removeChild()用法及代碼示例
- HTML DOM hasAttributes()用法及代碼示例
- HTML DOM focus()用法及代碼示例
- HTML DOM hasChildNodes()用法及代碼示例
- HTML method屬性用法及代碼示例
注:本文由純淨天空篩選整理自ProgrammerAnvesh大神的英文原創作品 HTML | DOM exitFullscreen() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。