471,887 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

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?



Thanks,
Jul 28 '08 #1
1 1379
mrhoo
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
reply views Thread by YellowAndGreen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.