zoukankan      html  css  js  c++  java
  • 获取屏幕的宽度和高度

      在js中,特别是在一些功能,比如底部返回哪些按钮等,经常需要用到,这里综合运用以下,以便可以以后快速获取:

    /**
     * 获取屏幕的宽度和高度
     * @returns {*}
     */
    function client() {
        if(window.innerWidth){ // ie9+ 最新的浏览器
            return {
                 window.innerWidth,
                height: window.innerHeight
            }
        }else if(document.compatMode === "CSS1Compat"){ // W3C
            return {
                 document.documentElement.clientWidth,
                height: document.documentElement.clientHeight
            }
        }
    
        return {
             document.body.clientWidth,
            height: document.body.clientHeight
        }
    }

      好了,至于怎么引入这个文件,想必大家都很熟悉了,这里就不一一介绍了。

  • 相关阅读:
    html5 File api 上传案例
    DOM操作
    箭头函数
    js 高级函数
    导入导出封装
    函数
    哲学/文学
    qtMd5 加密算法
    生活感悟
    C# 小技巧
  • 原文地址:https://www.cnblogs.com/songtianfa/p/12187819.html
Copyright © 2011-2022 走看看