Click to See Complete Forum and Search --> : offsetTop on tables


michelle
06-24-2003, 06:43 AM
Code at the bottom...

As far as I understood it, offsetTop is the distance in pixels from the top of the web browser window to to beginning of an element. But in the case below, it doesn't work.
Howcome?

// Michelle


<script>
function testa(num) {
var tableId = "t"+num;
document.getElementById('MenuLayer').style.top = document.getElementById(tableId).offsetTop;
}
</script>

</head>

<body>

<a href="#" onClick="testa(3)">test</a><br>
<table width="300" cellspacing="0" cellpadding="0" border="1">
<tr>
<td>dsfg</td>
</tr>
<tr>
<td>dsfg</td>
</tr>
<tr>
<td id=t3>dsg</td>
</tr>
</table>

<div id="MenuLayer" style="position:absolute; background-color:gray; layer-background-color:gray; visibility:visible;">
bla bla bla
</div>

michelle
06-24-2003, 07:34 AM
How can I do this?
How would I go about constructing a function that count downwards from the chosen object?

function getRealOffsetTop(objName) {

// loop until no parent is available
// Add the offset of this to the sum of all offsets
}

michelle
06-24-2003, 08:26 AM
OK... now I get it. I thought I was supposed to look in dumpObject.js..
Thanks!

// Michelle