js 控制全屏及退出全屏

/**
 * 全屏显示
 */
function full() {
	var element = document.documentElement;
	var method = element.requestFullScreen || //W3C
				 element.webkitRequestFullScreen || //FireFox
				 element.mozRequestFullScreen || //Chrome等
				 element.msRequestFullScreen; //IE11
	if(method) {
		method.call(element);
	}
	else if(typeof window.ActiveXObject != "undefined") {
		var active = new ActiveXObject("WScript.Shell");
		if(active) active.SendKeys("{F11}");
	}
}
/**
 * 取消全屏
 */
function exitFull() {
	var element = document;
	var method = element.cancelFullScreen || //W3C
				 element.webkitCancelFullScreen  || //FireFox
				 element.mozCancelFullScreen || //Chrome等
				 element.exitFullScreen; //IE11
	if (method) {
		method.call(element);
	}
	else if(typeof window.ActiveXObject != "undefined") {
		var active = new ActiveXObject("WScript.Shell");
		if(active) active.SendKeys("{F11}");
	}
}

 

你可能感兴趣的:(js 控制全屏及退出全屏)