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

推荐订阅源

D
Docker
Microsoft Azure Blog
Microsoft Azure Blog
云风的 BLOG
云风的 BLOG
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
LangChain Blog
P
Privacy & Cybersecurity Law Blog
Hugging Face - Blog
Hugging Face - Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
A
Arctic Wolf
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
The GitHub Blog
The GitHub Blog
P
Privacy International News Feed
WordPress大学
WordPress大学
U
Unit 42
S
Securelist
T
The Exploit Database - CXSecurity.com
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
Latest news
Latest news
Hacker News: Ask HN
Hacker News: Ask HN
小众软件
小众软件
Know Your Adversary
Know Your Adversary
The Cloudflare Blog
V
Vulnerabilities – Threatpost
The Hacker News
The Hacker News
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
Security Latest
Security Latest
Google DeepMind News
Google DeepMind News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - Franky
Y
Y Combinator Blog
博客园 - 叶小钗
Security Archives - TechRepublic
Security Archives - TechRepublic
Google DeepMind News
Google DeepMind News
N
Netflix TechBlog - Medium
S
Secure Thoughts
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 司徒正美
M
MIT News - Artificial intelligence

博客园 - yulei

几个css技巧 HttpWebRequest 发送 POST实现自动用户登录 - yulei jquery selector 基础 - yulei asp.net ajax实现:Jquery+Json - yulei - 博客园 smtp协议 发送带附件的邮件 控制滚动条 (转)防数据库批量注入JS 转载 JS获取CSS属性值 - yulei - 博客园 HttpCompress相关问题解决方法 - yulei - 博客园 C#发送Email邮件方法总结 数据导出到excel文件给客户端下载的几种方法(转) ndoc2007,生成注释文档,支持泛型,2.0,中文注解,部分汉化 IE和Firefox浏览器CSS网页布局不同点 - yulei - 博客园 仿DVBBS下拉菜单效果 webClient下载进度条 asp.net下URL网址重写成.html格式、RSS、OPML的知识总结 导出excel 使用AD724的RGB→NTSC/PAL制信号转换电路 AV-RF转换器的制作
通用获得网页的实际大小的javascript函数
yulei · 2009-03-26 · via 博客园 - yulei

通用获得网页的实际大小的javascript函数


    在做web2.0风格的弹出窗口的时候,经常需要把背景变暗和屏蔽。这时就需要得到一个网页的宽高数据。这里就会有很多细节和兼容性问题。经过长期摸索, 现提供以下函数,希望对大家有用。这个函数的具体作用是获得网页的高度和宽度,如果网页没有窗口可见区域高的时候则取窗口的可见区域高度和宽度。返回值为 一个对象 ,例如 { width:123, height:345}。现在兼容几乎所有的浏览器。

javascript代码:

function get_page_size()
{
    var re = {};
    if (document.documentElement && document.documentElement.clientHeight)
    {
        var doc = document.documentElement;
        re.width = (doc.clientWidth>doc.scrollWidth)?doc.clientWidth-1:doc.scrollWidth;
        re.height = (doc.clientHeight>doc.scrollHeight)?doc.clientHeight:doc.scrollHeight;
    }
    else
    {
        var doc = document.body;
        re.width = (window.innerWidth>doc.scrollWidth)?window.innerWidth:doc.scrollWidth;
        re.height = (window.innerHeight>doc.scrollHeight)?window.innerHeight:doc.scrollHeight;
    }
    return re;
}