js控制頁面的全屏展示和退出全屏顯示的方法
更新時間:2015年03月10日 09:42:35 作者:JESTER_WILL
這篇文章主要介紹了js控制頁面的全屏展示和退出全屏顯示的方法,實例分析了javascript控制頁面全屏效果的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了js控制頁面的全屏展示和退出全屏顯示的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
復制代碼 代碼如下:
<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<body>
<div style="margin:0 auto;height:600px;width:700px;">
<button id="btn">js控制頁面的全屏展示和退出全屏顯示</button>
<div id="content" style="margin:0 auto;height:500px;width:700px; background:#ccc;" >
<h1>js控制頁面的全屏展示和退出全屏顯示</h1>
</div>
</div>
</body>
<script language="JavaScript">
document.getElementById("btn").onclick=function(){
var elem = document.getElementById("content");
requestFullScreen(elem);
};
function requestFullScreen(element) {
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
if (requestMethod) {
requestMethod.call(element);
} else if (typeof window.ActiveXObject !== "undefined") {
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}
</script>
</html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<body>
<div style="margin:0 auto;height:600px;width:700px;">
<button id="btn">js控制頁面的全屏展示和退出全屏顯示</button>
<div id="content" style="margin:0 auto;height:500px;width:700px; background:#ccc;" >
<h1>js控制頁面的全屏展示和退出全屏顯示</h1>
</div>
</div>
</body>
<script language="JavaScript">
document.getElementById("btn").onclick=function(){
var elem = document.getElementById("content");
requestFullScreen(elem);
};
function requestFullScreen(element) {
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
if (requestMethod) {
requestMethod.call(element);
} else if (typeof window.ActiveXObject !== "undefined") {
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}
</script>
</html>
希望本文所述對大家的javascript程序設(shè)計有所幫助。
相關(guān)文章
js匿名函數(shù)的調(diào)用示例(形式多種多樣)
匿名函數(shù)就是沒有實際名字的函數(shù),javaScript的匿名函數(shù)形式多樣,下面就一一為大家羅列出來2014-08-08
在Postman的腳本中如何使用pm對象獲取接口的請求參數(shù)
這篇文章主要介紹了在Postman的腳本中如何使用pm對象獲取接口的請求參數(shù),本文通過實例代碼圖文相結(jié)合給大家介紹的非常詳細,需要的朋友可以參考下2023-09-09
js中用window.open()打開多個窗口的name問題
這篇文章主要介紹了js中用window.open()打開多個窗口的問題,需要的朋友可以參考下2014-03-03
JavaScript中Require調(diào)用js的實例分享
下面小編就為大家?guī)硪黄狫avaScript中Require調(diào)用js的實例分享。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-10-10

