<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <button onclick="fullScreen()">现代浏览器全屏</button>
<button onclick="exitScreen()">现代浏览器退出</button>
<button onclick="iefull()">低版本ie全屏</button> </body> <script type="text/javascript"> function fullScreen(){ var el = document.documentElement; var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen; if(typeof rfs != "undefined" && rfs) { rfs.call(el); }; return; } function exitScreen(){ if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } if(typeof cfs != "undefined" && cfs) { cfs.call(el); } } function iefull(){ var el = document.documentElement; var rfs = el.msRequestFullScreen; if(typeof window.ActiveXObject != "undefined") { var wscript = new ActiveXObject("WScript.Shell"); if(wscript != null) { wscript.SendKeys("{F11}"); } } } </script> </html>
|