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

推荐订阅源

Jina AI
Jina AI
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
量子位
H
Help Net Security
Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
L
LINUX DO - 最新话题
A
Arctic Wolf
博客园_首页
S
Securelist
S
Secure Thoughts
Google DeepMind News
Google DeepMind News
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
酷 壳 – CoolShell
酷 壳 – CoolShell
Stack Overflow Blog
Stack Overflow Blog
N
Netflix TechBlog - Medium
Cyberwarzone
Cyberwarzone
小众软件
小众软件
T
Threatpost
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Blog — PlanetScale
Blog — PlanetScale
N
News and Events Feed by Topic
NISL@THU
NISL@THU
Forbes - Security
Forbes - Security
博客园 - 聂微东
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
H
Heimdal Security Blog
罗磊的独立博客
S
Security @ Cisco Blogs
B
Blog
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
Hacker News - Newest:
Hacker News - Newest: "LLM"
I
Intezer
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
The Cloudflare Blog
S
Schneier on Security
月光博客
月光博客
L
LINUX DO - 热门话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - 田了你

[ZF]开心一下 [转]Java jdbc数据库连接池总结! 一台机器部署N个server步骤 [转]软件开发者面试百问 09年的第一篇日志比已往的时候来得更早一些 - 田了你 - 博客园 [转]关于锚点 - 田了你 - 博客园 从今天开始每天写一篇日志咯 Telerik RadGrid 翻页问题解决 - 田了你 果然是本命年 javascript注册事件的四种方式 - 田了你 - 博客园 Tomcat5.x的项目部署 又被老板欺骗了 .net的优点变缺点(郁闷了一天) 2007.2.1 -----2007.4.1安排计划 关于NTKO_office的操作(从数据库中提取数据,写入到NTKO_office_Word中) [转]JS代码格式化工具(附源代码) 层的拖动 解决SQL2000乱码问题 ref与out
获得控件在页面上的绝对位置的方法
田了你 · 2007-01-11 · via 博客园 - 田了你

obj为控件对象。
function getAbsolutePos(obj)
{
    var pos = { x: 0, y: 0 };
    var offset_x = obj.clientLeft + 2;
    var offset_y = obj.clientTop + 2;
    function innerFunction()
    {
            while(obj)
            {
                pos.x += obj.offsetLeft;
                pos.y += obj.offsetTop;
                pos.x += obj.clientLeft;
                       pos.y += obj.clientTop;
                       /*如果需要计算滚动条
                       if(obj.scrollLeft)
                        pos.x += obj.clientLeft;
                       if(obj.scrollTop)
                               pos.y += obj.scrollTop;
                       */
                      
                obj=obj.offsetParent;
            }
        }
        innerFunction();
        pos.x -= offset_x;
        pos.y -= offset_y;
    return pos;
}