Welcome to WebmasterWorld Guest from 54.160.187.160

Forum Moderators: open

Message Too Old, No Replies

how to get_absolute_left(float + offsetLeft)

     
5:29 am on Apr 11, 2006 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 19, 2002
posts:372
votes: 0


there is an example code in msdn that tell u how to calc absolute top/left of a specified element.

function calc...(o) {
var l = o.offsetTop;
var p = o.offsetParent;

while (p!= null) {
if (ie && p.tagName == "TD") {
l += p.clientTop;
}
l += p.offsetTop;
p = p.offsetParent;
}
}

but it won't work with


<div style="float: left">abc</div>
<div style="float: right">123</div>
<div style="float: left">def<div id="obj">calc me</div></div>

how do u calc the obj?