做手机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. AcWing 157. 树形地铁系统 (hash判断树同构)打卡

    一些主要城市拥有树形的地铁系统,即在任何一对车站之间,有且只有一种方式可以乘坐地铁. 此外,这些城市大多数都有一个中央车站. 想象一下,你是一名在拥有树形地铁系统的城市游玩的游客,你想探索该城市完整的 ...

  2. Ajax请求参数为文件类型

    1.图片用get请求,回调函数中返回的数据就是流文件(至于是什么流文件还不清楚), 在回调函数中再使用post请求2.JS将文件像form表单一样提交到后台  :  https://www.cnblo ...

  3. shell 删除超过30天的文件和目录

    #!/bin/bash location="/root/sqlbak/" find $location -mtime +30 -type d |xargs rm -rf #删除目录 ...

  4. 拾遗:关于“尾递归”- tail recursion

    定义[个人理解]: 尾递归,即是将外层得出的常量计算因子,以函数参数的形式逐层向内传递,即内层调用整合外层调用的产出,整个递归的结果最终由最内层的一次函数调用得出:而通常的递归则是外层调用阻塞.等待内 ...

  5. 高级UI晋升之常用View(三)下篇

    更多Android高级架构进阶视频学习请点击:https://space.bilibili.com/474380680本篇文章将从WebView来介绍常用View: 一.WebView介绍 Andro ...

  6. 四(1)、springcloud之Ribbon初步配置

    1.概述 ​ Spring Cloud Ribbon是基于Netflix Ribbon实现的一套客户端 -负载均衡的工具.Ribbon是Netflix发布的开源项目,主要功能是提供客户端的软件负载均衡 ...

  7. Couleur(启发式 + 主席树)(终于补坑了)

    ZOJ Problem Set - 4053 Couleur Time Limit: 6 Seconds      Memory Limit: 131072 KB DreamGrid has an a ...

  8. akka-stream之异常处理

    背景介绍 在项目中使用了akk-stream的source.queue功能,如下: Pair<SourceQueueWithComplete<Integer>, Source< ...

  9. spring的组成模块

    spring的核心组件(骨骼架构)——   共同创建了Bean关系网络 Core:主要定义了资源的访问方式 Context:给spring提供一个运行时的环境 Bean:Bean的定义,创建以及解析 ...

  10. yes - 不断输出一个字符串,直到杀死其为止

    SYNOPSIS(总览) yes [OPTION]... [STRING]... DESCRIPTION(描述) 不断输出包括所有指定STRING(s)的一行,或者是`y'. --help 显示帮助并 ...