注册 X
我已阅读并同意  服务条款
首页 > IT技术笔记 > 查看笔记

浏览器全屏JS代码

点击复制

// 判断各种浏览器,找到正确的方法, 全屏
function requestFullScreen(element) {
	var requestMethod = element.requestFullScreen || //W3C
		element.webkitRequestFullScreen || //Chrome等
		element.mozRequestFullScreen || //FireFox
		element.msRequestFullScreen; //IE11
	if(requestMethod) {
		requestMethod.call(element);
	} else if(typeof window.ActiveXObject !== "undefined") { //for Internet Explorer
		var wscript = new ActiveXObject("WScript.Shell");
		if(wscript !== null) {
			wscript.SendKeys("{F11}");
		}
	}
}

//退出全屏 判断浏览器种类
function exitFull() {
	var exitMethod = document.exitFullscreen || //W3C
		document.mozCancelFullScreen || //Chrome等
		document.webkitExitFullscreen || //FireFox
		document.webkitExitFullscreen; //IE11
	if(exitMethod) {
		exitMethod.call(document);
	} else if(typeof window.ActiveXObject !== "undefined") { //for Internet Explorer
		var wscript = new ActiveXObject("WScript.Shell");
		if(wscript !== null) {
			wscript.SendKeys("{F11}");
		}
	}
}			
		

 打赏        分享



评论