通过下面的代码,可以实现网页元素进入全屏显示或退出全屏显示。
一、进入全屏的代码
function DivFullScreen() {
//进入全屏
var viewFullScreen = document.getElementById("试题修改面板");
if (viewFullScreen) {
//全屏
var docElm = document.getElementById("试题修改面板");
if (docElm.requestFullscreen) {
docElm.requestFullscreen();
} else if (docElm.msRequestFullscreen) {
docElm = document.body;
docElm.msRequestFullscreen();
} else if (docElm.mozRequestFullScreen) {
docElm.mozRequestFullScreen();
} else if (docElm.webkitRequestFullScreen) {
docElm.webkitRequestFullScreen();
}
}
}
二、退出全屏的代码
var viewFullScreen = document.getElementById("试题修改面板");
if (viewFullScreen) {
viewFullScreen.addEventListener("dblclick", function() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}, false);
}