网页前端设计

http://www.86y.org

搜索文章

js控制页面的全屏展示和退出全屏显示

用声音读出全文关注我吧
 2011/1/4 11:50:33 阅读次数:24178

js控制页面的全屏展示和退出全屏显示

  • <!DOCTYPE html>
  • <html>
  • <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  • <body >
  • <button id="btn" >js控制页面的全屏展示和退出全屏显示</button>
  • <div id="content" style="height:500px;width:500px;background:#fff">
  • <h1>js控制页面的全屏展示和退出全屏显示</h1>
  • </div>
  • </body>
  • <script language="JavaScript">
  • document.getElementById("btn").onclick=function(){
  • var elem = document.getElementById("content");
  • requestFullScreen(elem);
  • };
  • function requestFullScreen(element) {
  • var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
  • if (requestMethod) {
  • requestMethod.call(element);
  • } else if (typeof window.ActiveXObject !== "undefined") {
  • var wscript = new ActiveXObject("WScript.Shell");
  • if (wscript !== null) {
  • wscript.SendKeys("{F11}");
  • }
  • }
  • }
  • </script>
  • </html>

(完)


大家有什么问题或技术上的想法可以在此与大家分享,也可以加入前端爱好者QQ群(141999928)一起学习进步:【幸凡前端技术交流群】
如需转载请注明出处:http://www.86y.org/art_detail.aspx?id=106【js控制页面的全屏展示和退出全屏显示】幸凡学习网
0

如果您觉得本文的内容对您的学习有所帮助,捐赠与共勉,支付宝(左)或微信(右)

阅读全文内容关闭