By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,630 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,630 IT Pros & Developers. It's quick & easy.

Float Element Positions and IE

P: 45
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
Share this Question
Share on Google+
1 Reply

P: 428
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.