DHTML help

Status
Not open for further replies.
Hi!
I've got this piece of HTML code:


<STYLE>
.MainMenu{
border:0px;
position:relative;
visibility:visible;
}
</STYLE>
<BODY>
<table border="1" width="100%">
<tr>
<td align="center">

<div class="MainMenu" id="Menu">
<table width="730" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="570">pippo</td>
</tr>
</table>
</div>

</td>
</tr>
</table>
</BODY>


My question: is there a way to know the layer's xy position (bold code) on the page?
Thanks everyone
 

Keyan

Ars Centurion
334
Subscriptor++
If you're looking for the absolute position, this is what I've had to do:

code:<HR>
Code:
var element = document.getElementById("Menu");
var x = 0;
var y = 0;
while (element.offsetParent != null)
{
   x += element.offsetLeft;
   y += element.offsetTop;
   element = element.offsetParent;
}<P>// x and y now contain the div's absolute position
 
Status
Not open for further replies.