点击控件报表全屏JS
因为最近大屏展示的电脑没接键盘,需要用到点击的方式使网页报表全屏,所以加了这个功能,分享给小伙伴们。在要用的控件的事件里添加如下的代码就可以实现。
var docElm = document.documentElement;
var explorer = window.navigator.userAgent.toLowerCase();
if(explorer.indexOf('chrome')>0){//webkit
if (document.body.scrollHeight === window.screen.height && document.body.scrollWidth === window.screen.width) {
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
} else {
//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();
}
}
}else{//IE 9+ fireFox
if (window.outerHeight === window.screen.height && window.outerWidth === window.screen.width) {
if (document.exitFullscreen) {
document.exitFullscreen();
}
else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
}
else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
} else {
//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();
}
}
}
编辑于 2018-3-28 10:53