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

推荐订阅源

量子位
S
Securelist
MyScale Blog
MyScale Blog
Jina AI
Jina AI
罗磊的独立博客
The Cloudflare Blog
美团技术团队
博客园 - 叶小钗
阮一峰的网络日志
阮一峰的网络日志
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
雷峰网
雷峰网
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
博客园 - 聂微东
Y
Y Combinator Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
T
Tailwind CSS Blog
Attack and Defense Labs
Attack and Defense Labs
博客园_首页
Latest news
Latest news
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Hacker News
The Hacker News
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
U
Unit 42
D
Docker
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
T
Tor Project blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
B
Blog
Recent Announcements
Recent Announcements
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Security Latest
Security Latest
V2EX - 技术
V2EX - 技术
N
News | PayPal Newsroom
Microsoft Security Blog
Microsoft Security Blog

博客园 - 孤城浪子

[转].Net 中的许可证机制 [原]一步一步自己制作弹出框 PHP连接mysql数据库 - 孤城浪子 - 博客园 PHP文件上传 动态调用Web Service - 孤城浪子 - 博客园 [转]ASP.NET 2.0 下加密解密算法的封装 [转]fckeidtor配置 [转]加解密技术 - 孤城浪子 - 博客园 [转]服务器推技术 [JavaScript]简单跟随鼠标移动的文字 排序算法 [仿照CloudGamer]写的颜色渐变 Asp.Net用SmtpClient发送邮件 项目中遇到的Vss和Sql问题 [JavaScript]拖动对象 - 孤城浪子 - 博客园 [JavaScript]飘浮文字 C#文件打散合并 C#调用Excel的宏 [网上整理]C#合并Excel
[转]获取窗口 高 、宽 的JS代码
孤城浪子 · 2010-05-12 · via 博客园 - 孤城浪子

获取窗口 高 、宽 的JS代码

var getViewPortWidth = function()
{
var width = 0;

if ((document.documentElement) && (document.documentElement.clientWidth))
{
width = document.documentElement.clientWidth;
}
else if ((document.body) && (document.body.clientWidth))
{
width = document.body.clientWidth;
}
else if (window.innerWidth)
{
width = window.innerWidth;
}

return width;
};

var getViewPortHeight = function()
{
var height = 0;

if (window.innerHeight)
{
height = window.innerHeight - 18;
}
else if ((document.documentElement) && (document.documentElement.clientHeight))
{
height = document.documentElement.clientHeight;
}

return height;
};

var getContentHeight = function()
{
if ((document.body) && (document.body.offsetHeight))
{
return document.body.offsetHeight;
}

return 0;
};

var getViewPortScrollX = function()
{
var scrollX = 0;

if ((document.documentElement) && (document.documentElement.scrollLeft))
{
scrollX = document.documentElement.scrollLeft;
}
else if ((document.body) && (document.body.scrollLeft))
{
scrollX = document.body.scrollLeft;
}
else if (window.pageXOffset)
{
scrollX = window.pageXOffset;
}
else if (window.scrollX)
{
scrollX = window.scrollX;
}

return scrollX;
};

var getViewPortScrollY = function()
{
var scrollY = 0;

if ((document.documentElement) && (document.documentElement.scrollTop))
{
scrollY = document.documentElement.scrollTop;
}
else if ((document.body) && (document.body.scrollTop))
{
scrollY = document.body.scrollTop;
}
else if (window.pageYOffset)
{
scrollY = window.pageYOffset;
}
else if (window.scrollY)
{
scrollY = window.scrollY;
}

return scrollY;
};

作者:QLeelulu