做手机Web开发做浏览器兼容用到了,所以在网上找了些汇总下。

alert($(window).height()); //浏览器当前窗口可视区域高度 
alert($(document).height()); //浏览器当前窗口文档的高度 
alert($(document.body).height());//浏览器当前窗口文档body的高度 
alert($(document.body).outerHeight(true));//浏览器当前窗口文档body的总高度 包括border padding margin 
alert($(window).width()); //浏览器当前窗口可视区域宽度 
alert($(document).width());//浏览器当前窗口文档对象宽度 
alert($(document.body).width());//浏览器当前窗口文档body的高度 
alert($(document.body).outerWidth(true));//浏览器当前窗口文档body的总宽度 包括border padding margin 
 
// 获取页面的高度、宽度
function getPageSize() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
        xScroll = window.innerWidth + window.scrollMaxX;
        yScroll = window.innerHeight + window.scrollMaxY;
    } else {
        if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac    
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari    
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) { // all except Explorer    
        if (document.documentElement.clientWidth) {
            windowWidth = document.documentElement.clientWidth;
        } else {
            windowWidth = self.innerWidth;
        }
        windowHeight = self.innerHeight;
    } else {
        if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode    
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else {
            if (document.body) { // other Explorers    
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }
        }
    }       
    // for small pages with total height less then height of the viewport    
    if (yScroll < windowHeight) {
        pageHeight = windowHeight;
    } else {
        pageHeight = yScroll;
    }    
    // for small pages with total width less then width of the viewport    
    if (xScroll < windowWidth) {
        pageWidth = xScroll;
    } else {
        pageWidth = windowWidth;
    }
    arrayPageSize = new Array(pageWidth, pageHeight, windowWidth, windowHeight);
    return arrayPageSize;
}
 
// 滚动条
document.body.scrollTop;
$(document).scrollTop();

版权所有,转载请注明出处 本文出自:

版权所有,欢迎转载,转载请注明出处,谢谢

转载:jQuery 获取屏幕高度、宽度的更多相关文章

  1. js和jQuery 获取屏幕高度、宽度

    js获取屏幕高度,宽带 网页可见区域宽:document.body.clientWidth网页可见区域高:document.body.clientHeight网页可见区域宽:document.body ...

  2. jQuery 获取屏幕高度、宽度

    做手机Web开发做浏览器兼容用到了,所以在网上找了些汇总下. alert($(window).height()); //浏览器当前窗口可视区域高度alert($(document).height()) ...

  3. js获取屏幕高度宽度

    获取各种屏幕的宽度和高度Javascript: 网页可见区域宽: document.body.clientWidth网页可见区域高: document.body.clientHeight网页可见区域宽 ...

  4. jquery的height()和javascript的height总结,js获取屏幕高度

    jquery的height()和javascript的height总结,js获取屏幕高度 2014年9月18日 15048次浏览 引子 今天是九一八事变八十三周年,大家勿忘国耻!加油学习!经济和技术等 ...

  5. Android 获取屏幕高度,宽度,状态栏高度

    背景介绍: 到目前为止,android已经从1.5发展到目前的3.2,我们在写一个应用的时候,最常用到得就是获取屏幕高度,宽度,以及status bar的高度. 然而android系统变化太快了,从开 ...

  6. JS获取屏幕高度

    主要使用了document对象关于窗口的一些属性,这些属性的主要功能和用法如下. 要 得到窗口的尺寸,对于不同的浏览器,需要使用不同的属性和方法:若要检测窗口的真实尺寸,在netscape下需要使用w ...

  7. Android获取屏幕高度、标题高度、状态栏高度详解

    Android获取屏幕高度的方法主要由view提供 通过View提供的方法获取高度方式有两种: 1, 当前显示的view中直接获取当前view高宽2,通过Activity的getWindow().fi ...

  8. Jquery获对HTML控件的控制

    Jquery获对HTML控件的控制 1.获取控件的值 1.1.radio 1.1.1 获取一组radio被选中项的值  var item = $('input[name=items][checked] ...

  9. jQuery计算文本宽度和input标签根据输入字符动态自适应宽度的实现

    jQuery计算文本宽度的原理是利用html提供的<pre>标签,向dom中动态添加<pre>标签,标签里的内容就是要测试长度的文本,获取完长度之后再删除刚才添加的<pr ...

随机推荐

  1. 使用 windsor 实现IOC 和 AOP

    代码很简单,不多说. 对于拦截,windsor 使用动态代理的方式,即生成继承类的方式来实现的,因此无法拦截private 方法,因为无法在继承类中看见private方法. using System; ...

  2. Python练习题中做错题目

    1,一下代码执行的结果为 a = b = "julyedu.com" a = 'AI 教育' print(b) 答案: julyedu.com 要点: 在python中, 不可变对 ...

  3. 关于命令ride.py打不开RF,而是打开pycharm编辑器问题解决思路

    自从用RF工具做自动化测试以来,碰到过三次标题中的问题.头两次问别人解决了,第三次就自己动手解决,并记录下来. 第一次碰到这个问题,以为问题很小,没有放在心上,同事帮忙弄出来了. 别人帮忙弄的,记忆力 ...

  4. 从pcap文件中分析出数据包

    import dpkt import struct import sys,os f=file(sys.argv[1],"rb") pcap=dpkt.pcap.Reader(f) ...

  5. 国内pypi镜像

    V2EX pypi.v2ex.com/simple 豆瓣 http://pypi.douban.com/simple 阿里云(推荐使用) http://mirrors.aliyun.com/pypi/ ...

  6. 第四记 Java异常

    Java异常结构图 Java所有异常都是从Throwable继承而来,Throwable有两个子类,Error与Exception. Error是错误,对于所有的编译时期的错误以及系统错误都是通过Er ...

  7. hdu6331 /// Floyd+分块DP

    题目大意: 给定单向图的n m 为点数和单向边数 接下来m行给定 u v w 为边的起点终点和长度 给定q 为询问个数 接下来q行给定 x y k 求从x到y至少经过k条边的最短路长度 https:/ ...

  8. keepAlived常见问题

    1.脑裂问题 1.定义: 在一个高可用(HA)系统中,当关联着的两个结点互相之间断开通信时,本来为一个独立的对外提供服务的系统分裂为两个独立的结点,这时两个结点会争抢资源.(keepAlived 中表 ...

  9. 文件IO 例子

    例子1: 测试最多打开多少个文件 #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> # ...

  10. redis 分析rdb中key

    1.问题: 单位一个redis集群内存报警,想找出所有的key的列表? 2.解决办法: 网上搜索是可以用redis-rdb-tools 这个工具进行分析 (1)centos6 默认安装python2. ...