2019独角兽企业重金招聘Python工程师标准>>>

document.documentElement.clientHeight -->浏览器的高度

document.documentElement.scrollHeight 全文的高度

document.documentElement.scrollTop滚去的高度

<script>

function getInfo()
{
    var s = "";
    s += " 网页可见区域宽:"+ document.body.clientWidth;
    s += " 网页可见区域高:"+ document.body.clientHeight;
    s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)";
    s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)";
    s += " 网页正文全文宽:"+ document.body.scrollWidth;
    s += " 网页正文全文高:"+ document.body.scrollHeight;
    s += " 网页被卷去的高(ff):"+ document.body.scrollTop;
    s += " 网页被卷去的高(ie):"+ document.documentElement.scrollTop;
    s += " 网页被卷去的左:"+ document.body.scrollLeft;
    s += " 网页正文部分上:"+ window.screenTop;
    s += " 网页正文部分左:"+ window.screenLeft;
    s += " 屏幕分辨率的高:"+ window.screen.height;
    s += " 屏幕分辨率的宽:"+ window.screen.width;
    s += " 屏幕可用工作区高度:"+ window.screen.availHeight;
    s += " 屏幕可用工作区宽度:"+ window.screen.availWidth;
    s += " 你的屏幕设置是 "+ window.screen.colorDepth +" 位彩色";
    s += " 你的屏幕设置 "+ window.screen.deviceXDPI +" 像素/英寸";
    //alert (s);
}
getInfo();
</script>

在IE、FireFox、Opera下都可以使用
document.body.clientWidth
document.body.clientHeight
即可获得,很简单,很方便。
而在公司项目当中:
Opera仍然使用
document.body.clientWidth
document.body.clientHeight
可是IE和FireFox则使用
document.documentElement.clientWidth
document.documentElement.clientHeight
原来是W3C的标准在作怪啊
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
如果在页面中添加这行标记的话

在IE中:
document.body.clientWidth ==> BODY对象宽度
document.body.clientHeight ==> BODY对象高度
document.documentElement.clientWidth ==> 可见区域宽度
document.documentElement.clientHeight ==> 可见区域高度
在FireFox中:
document.body.clientWidth ==> BODY对象宽度
document.body.clientHeight ==> BODY对象高度
document.documentElement.clientWidth ==> 可见区域宽度
document.documentElement.clientHeight ==> 可见区域高度

在Opera中:
document.body.clientWidth ==> 可见区域宽度
document.body.clientHeight ==> 可见区域高度
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)
document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
而如果没有定义W3C的标准,则
IE为:
document.documentElement.clientWidth ==> 0
document.documentElement.clientHeight ==> 0
FireFox为:
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)
Opera为:
document.documentElement.clientWidth ==> 页面对象宽度(即BODY对象宽度加上Margin宽)document.documentElement.clientHeight ==> 页面对象高度(即BODY对象高度加上Margin高)

//获取滚动条的高度
function getPageScroll(){
var yScroll;
if (self.pageYOffset) {

yScroll = self.pageYOffset;
alert(yScroll)
} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict

yScroll = document.documentElement.scrollTop;
alert(yScroll)
} else if (document.body) {// all other Explorers
yScroll = document.body.scrollTop;
alert("zhoujian")
//alert(yScroll)
//alert("zj"+document.body.scrollTop)
}
arrayPageScroll = new Array('',yScroll)
//alert(yScroll)
return arrayPageScroll;
}
//获取页面实际大小
function getPageSize(){
   
    var xScroll, yScroll;
   
    if (window.innerHeight && window.scrollMaxY) {   
        xScroll = document.body.scrollWidth;
        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
        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 = windowWidth;
    } else {
        pageWidth = xScroll;
    }

arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
    return arrayPageSize;
}

G
M
T

Detect languageAfrikaansAlbanianAmharicArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CorsicanCroatianCzechDanishDutchEnglishEsperantoEstonianFilipinoFinnishFrenchFrisianGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHawaiianHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanKurdishKyrgyzLaoLatinLatvianLithuanianLuxembourgishMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPashtoPersianPolishPortuguesePunjabiRomanianRussianSamoanScots GaelicSerbianSesothoShonaSindhiSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshXhosaYiddishYorubaZulu AfrikaansAlbanianAmharicArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CorsicanCroatianCzechDanishDutchEnglishEsperantoEstonianFilipinoFinnishFrenchFrisianGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHawaiianHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanKurdishKyrgyzLaoLatinLatvianLithuanianLuxembourgishMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPashtoPersianPolishPortuguesePunjabiRomanianRussianSamoanScots GaelicSerbianSesothoShonaSindhiSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshXhosaYiddishYorubaZulu

Text-to-speech function is limited to 200 characters
Options : History : Feedback : Donate Close

转载于:https://my.oschina.net/botkenni/blog/1923570

js获得浏览器高度和宽度 参数相关推荐

  1. 编辑器js获取浏览器高度和宽度值(转)

    js获取浏览器高度和宽度值 网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeight 网页可见区域宽: docume ...

  2. js 获取浏览器高度和宽度值

    IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.d ...

  3. 不同浏览器JS获取浏览器高度和宽度

    摘自:http://blog.csdn.net/lai_gb/archive/2009/07/04/4320956.aspx IE中: document.body.clientWidth ==> ...

  4. js 获取浏览器高度和宽度值(多浏览器)

     IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 documen ...

  5. js 获取浏览器高度和宽度值(兼容多浏览器)

    IE中:  document.body.clientWidth ==> BODY对象宽度  document.body.clientHeight ==> BODY对象高度  documen ...

  6. java中如何设置浏览器宽度_[Java教程]关于JS中获取浏览器高度和宽度值的多种方法(多浏览器)_星空网...

    关于JS中获取浏览器高度和宽度值的多种方法(多浏览器) 2017-08-07 0 三种浏览器获取值方法 IE中: document.body.clientWidth ==> BODY对象宽度 d ...

  7. js获取浏览器窗口页面宽度、高度的方法 kaki 的博客

    js获取浏览器窗口页面宽度.高度的方法 不多说,直接上代码 alert($(window).height()); //浏览器时下窗口可视区域高度 alert($(document).height()) ...

  8. JS获取浏览器高度 并赋值给类

    JS获取浏览器宽高的兼容写法: var w = window.innerWidth || document.documentElement.clientWidth || document.body.c ...

  9. Js操作DOM及获取浏览器高度以及宽度

    在JavaScript中,经常会需要获取document文档元素,是HTML文档对象模型的缩写,HTML DOM 定义了用于 HTML 的一系列标准的对象,以及访问和处理 HTML 文档的标准方法. ...

  10. js 获取浏览器屏幕的宽度和高度

    分两种: 不包括滚动条和工具栏的宽度或高度: window.innerWidth; // 宽window.innerHeight; // 高 就是红框内的部分: 包括滚动条和工具栏的宽度或高度: wi ...

最新文章

  1. iOS开发中didSelectRowAtIndexPath tap事件响应延迟
  2. java fx消息通知,Java的FX 2警报声
  3. sql server 索引阐述系列五 索引参数与碎片
  4. who i am !
  5. 清空oracle的注册表,Oracle中清除注册表
  6. Java实现将阿拉伯数字转换为中文数字123=》一二三
  7. bex5 mysql_bex5 库存系统的增删改查等功能对MYSQL数据库的维护操作 Windows Develop 276万源代码下载- www.pudn.com...
  8. 金蝶盘点机PDA仓库条码管理:仓库如何盘点
  9. C语言函数取大,C语言函数大全(部分)
  10. opencv检测动态物体
  11. 百度收录自动化提交脚本 - python
  12. 【2021版】吐血整理_专升本计算机文化基础—Excel2010
  13. 5Gwifi和手机5G区别
  14. 登录页面+注册+连接数据库示例
  15. “插座”,“充电宝”,“数据线”用英语怎么说?
  16. K_A18_001 基于STM32等单片机采集MQ2传感参数串口与OLED0.96双显示
  17. 星球专享 | 关于播放器的一次项目实践~~
  18. 显卡,CPU,GPU和CUDA的关系与区别
  19. 最短路径算法-迪杰斯特拉(Dijkstra)
  20. wordpress账号无法登陆_wordpress后台无法登陆的解决办法

热门文章

  1. 正态分布下贝叶斯决策的特例(三)
  2. python决策树分类wine_Python写算法:二元决策树
  3. 查看docker镜像内部端口号_Docker 安装部署
  4. 搜狐校园“情感分析×推荐排序“算法大赛 AutoX方案 转载poteman
  5. 2021-09-13排序学习的特征
  6. 324.摆动排序II
  7. 操作系统课设 Nachos 实验二:Nachos 的 Makefiles
  8. 基于离线策略的强化学习(PPO)
  9. 复旦nlp实验室 nlp-beginner 任务二:基于深度学习的文本分类
  10. mysql 密码sa_重置MySQL root密码