怎么让html页面加载自动f11_html5 js 实现浏览器全屏效果(F11)

能兼容google chrome 15 +, safri5.1+,firfox10+,IE11支持 、我只试验了火狐可以、360、以及IE8是没有成功滴、下面给大家发下代码、复制到HTML的页面就可以实现啦!

function kaishi()

{

var docElm = document.documentElement;

//W3C

if (docElm.requestFullscreen) {

docElm.requestFullscreen();

}

//FireFox

else if (docElm.mozRequestFullScreen) {

docElm.mozRequestFullScreen();

}

//Chrome等

else if (docElm.webkitRequestFullScreen) {

docElm.webkitRequestFullScreen();

}

//IE11

else if (elem.msRequestFullscreen) {

elem.msRequestFullscreen();

}

}

function guanbi() {

if (document.exitFullscreen) {

document.exitFullscreen();

}

else if (document.mozCancelFullScreen) {

document.mozCancelFullScreen();

}

else if (document.webkitCancelFullScreen) {

document.webkitCancelFullScreen();

}

else if (document.msExitFullscreen) {

document.msExitFullscreen();

}

}

document.addEventListener("fullscreenchange", function () {

fullscreenState.innerHTML = (document.fullscreen) ? "" : "not ";

}, false);

document.addEventListener("mozfullscreenchange", function () {

fullscreenState.innerHTML = (document.mozFullScreen) ? "" : "not ";

}, false);

document.addEventListener("webkitfullscreenchange", function () {

fullscreenState.innerHTML = (document.webkitIsFullScreen) ? "" : "not ";

}, false);

document.addEventListener("msfullscreenchange", function () {

fullscreenState.innerHTML = (document.msFullscreenElement) ? "" : "not ";

}, false);

你可能感兴趣的:(怎么让html页面加载自动f11_html5 js 实现浏览器全屏效果(F11))