标签:style blog http io ar color os 使用 sp
function requestFullScreen(element) { if (element.requestFullscreen) element.requestFullscreen(); else if (element.msRequestFullscreen) element.msRequestFullscreen(); else if (element.mozRequestFullScreen) element.mozRequestFullScreen(); else if (element.webkitRequestFullscreen) element.webkitRequestFullscreen(); } function cancelFullScreen() { if (document.exitFullscreen) document.exitFullscreen(); else if (document.msExitFullscreen) document.msExitFullscreen(); else if (document.mozCancelFullScreen) document.mozCancelFullScreen(); else if (document.webkitExitFullscreen) document.webkitExitFullscreen(); }
function isFullScreen() { return (document.fullScreenElement && document.fullScreenElement !== null) || document.mozFullScreen || document.webkitIsFullScreen; } function toggleFullScreen(element) { if (isFullScreen()) cancelFullScreen(); else requestFullScreen(element || document.documentElement); }
function toggleFullScreen(element) { requestFullScreen(element || document.documentElement); cancelFullScreen(); }
完整代码参考:
<html> <head> <meta charset="utf-8"> <title></title> <script src="../js/jquery-1.10.1.min.js"></script> <script> function isFullScreen() { return (document.fullScreenElement && document.fullScreenElement !== null) || document.mozFullScreen || document.webkitIsFullScreen; } function requestFullScreen(element) { if (element.requestFullscreen) element.requestFullscreen(); else if (element.msRequestFullscreen) element.msRequestFullscreen(); else if (element.mozRequestFullScreen) element.mozRequestFullScreen(); else if (element.webkitRequestFullscreen) element.webkitRequestFullscreen(); } function cancelFullScreen() { if (document.exitFullscreen) document.exitFullscreen(); else if (document.msExitFullscreen) document.msExitFullscreen(); else if (document.mozCancelFullScreen) document.mozCancelFullScreen(); else if (document.webkitExitFullscreen) document.webkitExitFullscreen(); } function toggleFullScreen(element) { requestFullScreen(element || document.documentElement); cancelFullScreen(); } $(document).ready(function(){ $("#exit").click(function(){ toggleFullScreen(document.body); }); }); </script> </head> <body> <div style="padding-top:300px;"></div> <button id="exit">退出</button> </body> </html>
标签:style blog http io ar color os 使用 sp
原文地址:http://www.cnblogs.com/walden1024/p/4147714.html