469,325 Members | 1,365 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,325 developers. It's quick & easy.

Float Element Positions and IE

I am trying to get the position of an element, and have it working in all the latest browsers other than IE. I want to get the current position on the page. I am using float Left or Right for placing the elements and this has allowed me to skip using tables to layout the page. The draw back I am having, is simply IE gives me the position me the offsetTop as always 0 and I am assuming that left is relative to the current container. How can I get the current position of an element within all browsers, no matter how I place an element?

Jul 28 '08 #1
1 1325
428 256MB
Expand|Select|Wrap|Line Numbers
  1. document.getElementXY= function(hoo){    
  2.     var T= 0, L= 0;
  3.     while(hoo){
  4.         L+= hoo.offsetLeft;
  5.         T+= hoo.offsetTop;
  6.         hoo= hoo.offsetParent;
  7.     }
  8.     return[L,T];
  9. }
Jul 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Alejandro Calbazana | last post: by
11 posts views Thread by Joriveek | last post: by
3 posts views Thread by hantechs | last post: by
22 posts views Thread by ashkaan57 | last post: by
2 posts views Thread by Ben C | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.