js模拟F11页面全屏显示

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>测试全屏</title> </head> <body> <button>全屏按钮</button> <div> <div>退出全屏</div> </div> <script type="text/javascript"> var btn = document.getElementById('btn'); var content = document.getElementById('content'); btn.onclick = function(){ console.log(content); fullScreen(content); } var quite = document.getElementById('quite'); quite.onclick = function(){ exitFullScreen(); } function fullScreen(el) { var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen, wscript; if(typeof rfs != "undefined" && rfs) { rfs.call(el); return; } if(typeof window.ActiveXObject != "undefined") { wscript = new ActiveXObject("WScript.Shell"); if(wscript) { wscript.SendKeys("{F11}"); } } } function exitFullScreen(el) { var el= document, cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen, wscript; if (typeof cfs != "undefined" && cfs) { cfs.call(el); return; } if (typeof window.ActiveXObject != "undefined") { wscript = new ActiveXObject("WScript.Shell"); if (wscript != null) { wscript.SendKeys("{F11}"); } } } </script> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/60a04787aeff3c1dc1abfdd004048d85.html