var inFullScreen = false; // flag to show when full screen
var fsClass = document.getElementsByClassName("imgFullNormal");
for (var i = 0; i < fsClass.length; i++) {
fsClass[i].addEventListener("click", function (evt) {
if (inFullScreen == false) {
makeFullScreen(evt.target); // open to full screen
} else {
reset();
}
}, false);
}
function makeFullScreen(divObj) {
if (divObj.requestFullscreen) {
divObj.requestFullscreen();
}
else if (divObj.msRequestFullscreen) {
divObj.msRequestFullscreen();
}
else if (divObj.mozRequestFullScreen) {
divObj.mozRequestFullScreen();
}
else if (divObj.webkitRequestFullscreen) {
divObj.webkitRequestFullscreen();
}
inFullScreen = true;
return;
}
function reset() {
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
inFullScreen = false;
return;
}
使用上面的代码,我可以使IE和Mozila Firefox全屏显示。但它变黑了,我的意思是背景。
基本上页面上有一个按钮。我希望通过单击按钮在全屏模式下显示页面。
有人请帮忙。