移动端h5页面全面屏判断

Arthur
2021-12-27 / 0 评论 / 203 阅读 / 正在检测是否收录...

移动端h5页面全面屏判断

  • 简单封装

    /**判断屏幕大小 */
    function  judgeBigScreen() {  //,这里根据返回值 true 或false ,返回true的话 则为全面屏 
      let result = false;
          const rate = window.screen.height / window.screen.width;    
          let limit =  window.screen.height == window.screen.availHeight ? 1.8 : 1.65; // 临界判断值  
    
     // window.screen.height为屏幕高度
    //  window.screen.availHeight 为浏览器 可用高度
    
          if (rate > limit) {
          result = true;
          }
          return result;
      };
    
      //自动执行匿名函数
    (function() {
      $().ready(function() {
          judgeBigScreen();//判断手机是否为全面屏
      });
    })();  
0
如果你觉得文章还不错,可以请我喝杯咖啡啊哈哈哈
wechat alipay

评论 (0)

取消