Float Element Positions and IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Leo Smith
    New Member
    • Mar 2007
    • 45

    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,
  • mrhoo
    Contributor
    • Jun 2006
    • 428

    #2
    Code:
    document.getElementXY= function(hoo){	
    	var T= 0, L= 0;
    	while(hoo){
    		L+= hoo.offsetLeft;
    		T+= hoo.offsetTop;
    		hoo= hoo.offsetParent;
    	}
    	return[L,T];
    }

    Comment

    Working...