通过jquery监听div双击全屏再次双击恢复demo
$(".Box").on("dblclick", function(){ var docId=$(this).attr("id"); var height=document.getElementById(docId); var fullscreenElement = document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement; console.log(fullscreenElement); if(docId&&fullscreenElement==null){ launchIntoFullscreen(height); }else{ exitFullscreen(); } }); //全屏显示 function launchIntoFullscreen(element) { if(element.requestFullscreen){ element.requestFullscreen(); } else if(element.mozRequestFullScreen) { element.mozRequestFullScreen(); } else if(element.webkitRequestFullscreen) { element.webkitRequestFullscreen(); } else if(element.msRequestFullscreen) { element.msRequestFullscreen(); } } //屏幕恢复 function exitFullscreen() { if(document.exitFullscreen) { document.exitFullscreen(); } else if(document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if(document.webkitExitFullscreen) { document.webkitExitFullscreen(); } }
$(".Box").on("dblclick", function(){ var docId=$(this).attr("id"); var height=document.getElementById(docId); var fullscreenElement = document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement; console.log(fullscreenElement); if(docId&&fullscreenElement==null){ launchIntoFullscreen(height); }else{ exitFullscreen(); } }); //全屏显示 function launchIntoFullscreen(element) { if(element.requestFullscreen){ element.requestFullscreen(); } else if(element.mozRequestFullScreen) { element.mozRequestFullScreen(); } else if(element.webkitRequestFullscreen) { element.webkitRequestFullscreen(); } else if(element.msRequestFullscreen) { element.msRequestFullscreen(); } } //屏幕恢复 function exitFullscreen() { if(document.exitFullscreen) { document.exitFullscreen(); } else if(document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if(document.webkitExitFullscreen) { document.webkitExitFullscreen(); } }
春有百花秋有月,夏有凉风冬有雪!