项目里面有一个需要实现浏览器全屏 也就是F11的效果
主流的浏览器都支持 可恶的IE9以下不支持!!!!
$("#fullscreen").bind("click",function () {
if($("#fullscreen").text() == "全屏显示"){
var a = document.documentElement;
//W3C
if (a.requestFullscreen) {
a.requestFullscreen();
}
//FireFox
else if (a.mozRequestFullScreen) {
a.mozRequestFullScreen();
}
//Chrome等
else if (a.webkitRequestFullScreen) {
a.webkitRequestFullScreen();
}
//IE11
else if (a.msRequestFullscreen) {
a.msRequestFullscreen();
}
$("#fullscreen").text("关闭全屏");
}else if($("#fullscreen").text() =='关闭全屏' ){
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
$("#fullscreen").text('全屏显示')
}
})