平時(shí)寫頁面,因?yàn)樽龅氖窍到y(tǒng)界面齐蔽,客戶對象是工作人員使用两疚,所以經(jīng)常遇到需要全屏功能的系統(tǒng)。
不墨跡含滴,直接上代碼
開啟全屏:
var el = document.documentElement;
var rfs = el.requestFullScreen || el.webkitRequestFullScreen ||
el.mozRequestFullScreen || el.msRequestFullScreen;
if (rfs) { //typeof rfs != "undefined" && rfs
rfs.call(el);
} else if (typeof window.ActiveXObject != "undefined") {
//for IE诱渤,這里其實(shí)就是模擬了按下鍵盤的F11,使瀏覽器全屏
var wscript = new ActiveXObject("WScript.Shell");
if (wscript != null) {
wscript.SendKeys("{F11}");
}
}
退出全屏
var el = document;
var cfs = el.cancelFullScreen || el.webkitCancelFullScreen ||
el.mozCancelFullScreen || el.exitFullScreen;
if (cfs) { //typeof cfs != "undefined" && cfs
cfs.call(el);
} else if (typeof window.ActiveXObject != "undefined") {
//for IE谈况,這里和fullScreen相同勺美,模擬按下F11鍵退出全屏
var wscript = new ActiveXObject("WScript.Shell");
if (wscript != null) {
wscript.SendKeys("{F11}");
}
}
贈送小方法
'20170710'.replace(/(\d{4})(\d{2})(\d{2})/g,'$1-$2-$3'); // 2017-07-10