[Javascript] Getting element coordinates.

Hakan M. hakan at backbase.com
Tue Nov 18 11:13:34 CST 2003


Hello list.

Problem: I need to determine the _exact_ coordinates of an element on my 
page, relative to the documents top/leftmost corner. It has to work in 
IE5.0+ and Mozilla, both on Windows platform. It has to work on _all_ 
elements - static, relative, absolute, float, you name it.

Research suggests:
Check the discussed browser flaws on ppks page.
<http://www.quirksmode.org/js/findpos.html>

Solution: None? I'm pondering on a function that iterates up, adding 
borders (if IE5->IE6) and checking for relative positioning and stop if 
I find any (if IE5.5) else continue until you run into...

But it doesn't feel right. Any suggestions, or is it really this bad? 
(Someone please kill all employees at Microsoft?)

Hakan




More information about the Javascript mailing list