我想要一个简单的功能来切换全屏。这是我写的:
function toggleFullScreen() {
var elem = document.documentElement,
request = elem.requestFullscreen || elem.msRequestFullscreen || elem.mozRequestFullScreen || elem.webkitRequestFullscreen,
exit = document.exitFullscreen || document.msExitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen;
if (!document.fullscreenElement && !document.msFullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement) {
request.call(elem);
} else {
exit.call(document);
}
}
任何更好或更简单的解决方案? 感谢。