惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
博客园 - Franky
F
Fortinet All Blogs
D
Docker
博客园 - 司徒正美
腾讯CDC
Recent Announcements
Recent Announcements
The Cloudflare Blog
B
Blog RSS Feed
GbyAI
GbyAI
T
Tailwind CSS Blog
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志

博客园 - 王祥 @ dot net 驿站

阿里云服务器Node环境配置 国内最快的jquery cdn HTML5 localStorage与document.domain设置问题 在FreeBSD上搭建Mac的文件及time machine备份服务 2012年年终总结:这一年,我玩大了 批处理操作压缩文件 为前端开发人员制作chrome扩展一枚jsbeautifier chrome中国版更新列表 自己总结的一些wap知识-WAP站点的MIME类型有哪些?如何添加? chrome os Google 可视化 API 很好,很强大! jquery中ajax方法提交数据时,中文乱码问题解决。 javascripter之配合dot net工程师。 关于虚函数一个很好的解释 DataRow对象数据绑定问题 - 王祥 @ dot net 驿站 修改程序之感悟 自己的个人网站js中国正逐步完善着。 一个能描述erp系统的小故事。 计划学习研究模板引擎。学习stringtemplate先
关于浏览器的可视大小
王祥 @ dot net 驿站 · 2008-08-01 · via 博客园 - 王祥 @ dot net 驿站

ie6之前的版本,窗口的可视大小body元素的大小。html标记是隐藏的。

而对于现代浏览器,窗口的可视大小是html元素的大小。html、body元素对应到javascript中分别为document.documentElement、document.body.

因此ie6以后的版本,ff,safari的可视宽度和高度为:

var windowWidth = document.documentElement.clientWidth || document.body.clientWidth;
var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;

opera则以body元素计算窗口的可视大小:

windowWidth = document.body.clientWidth;
    windowHeight 
= document.body.clientHeight;

因此,计算浏览器的可视大小应该表示为:

var windowWidth = document.documentElement.clientWidth || document.body.clientWidth;
var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;//标准下,opera的窗口的可是高度为document.body.clientWidth
if (window.opera)
{
    windowWidth 
= document.body.clientWidth;
    windowHeight 
= document.body.clientHeight;
}