zoukankan      html  css  js  c++  java
  • js获取页面宽高及浏览器宽高

         //返回页面的高度
            function pageHeight() {
                if (window.innerHeight && window.scrollMaxY) { yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight) { yScroll = document.body.scrollHeight; } else { yScroll = document.body.offsetHeight; }
                return yScroll;
            }
    
            //返回页面的宽度
            function pageWidth() {
                if (window.innerWidth && window.scrollMaxX) { xScroll = window.innerWidth + window.scrollMaxX; } else if (document.body.scrollWidth > document.body.offsetWidth) { xScroll = document.body.scrollWidth; } else { xScroll = document.body.offsetWidth; }
                return xScroll;
            }
    
            //返回浏览器的高度
            function windowHeight() {
                return (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
            }
    
            //返回浏览器的宽度
            function windowWidth() {
                return (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
            }
    

      

    作者:达奇
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    SQLite Helper
    VS2015
    SQLite connection strings
    DELPHI中四种EXCEL访问技术实现
    jQuery
    JQuery笔记
    一张图明白jenkins和docker作用
    多线程实现的4中方法
    线程池ThreadPoolExecutor分析
    Spring Boot配置文件放在jar外部
  • 原文地址:https://www.cnblogs.com/dachie/p/2995412.html
Copyright © 2011-2022 走看看