function toggleFullScreen() {
var isFull = window.fullScreen || document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || false;
var de = document.documentElement;
if (isFull === false) {
if (de.requestFullscreen) {
de.requestFullscreen();
} else if (de.mozRequestFullScreen) {
de.mozRequestFullScreen();
} else if (de.webkitRequestFullScreen) {
de.webkitRequestFullScreen();
} else if (de.msRequestFullscreen) {
de.msRequestFullscreen();
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
}
参考:
https://www.cnblogs.com/freeweb/p/5736411.html
ps:如果涉及到iframe跨域,可以通过possmessage通知父级执行全屏