其他分享
首页 > 其他分享> > 原生js 实现div全屏效果

原生js 实现div全屏效果

作者:互联网

//全屏
function fullScreen(el) {
var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen,
wscript;

if(typeof rfs != "undefined" && rfs) {
rfs.call(el);
return;
}

if(typeof window.ActiveXObject != "undefined") {
wscript = new ActiveXObject("WScript.Shell");
if(wscript) {
wscript.SendKeys("{F11}");
}
}
}

//退出全屏
function exitFullScreen(el) {
var el= document,
cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen,
wscript;

if (typeof cfs != "undefined" && cfs) {
cfs.call(el);
return;
}

if (typeof window.ActiveXObject != "undefined") {
wscript = new ActiveXObject("WScript.Shell");
if (wscript != null) {
wscript.SendKeys("{F11}");
}
}
}

 

注:el 为document对象

原文地址:https://unnue.com/article/49

标签:rfs,el,undefined,wscript,ActiveXObject,js,全屏,div,cfs
来源: https://blog.csdn.net/u011293970/article/details/90510630