首页 > Web开发 > 详细

js实现全屏

时间:2018-01-25 12:24:16      阅读:215      评论:0      收藏:0      [点我收藏+]

 

document.getElementById("btn").onclick=function(){
  var elem = document.getElementById("content");
    requestFullScreen(elem);
    /*
     注意这里的样式的设置表示全屏显示之后的样式,
     退出全屏后样式还在,
     若要回到原来样式,需在退出全屏里把样式还原回去
     (见写法三)
     */
    elem.style.height = ‘800px‘;
    elem.style.width = ‘100%‘;
 };
 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}");
       }
     }
 }

  代码来源:http://www.jb51.net/article/101692.htm

  这个可以使选定的内容全屏而不是页面上所有的内容全屏,不过这个有个缺点是高度不能铺满。

js实现全屏

原文:https://www.cnblogs.com/yaoya/p/8350561.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!