offsetTop

F

Francisco

Hi all,

I have a div (divI) inner another div (divM), when i request the
offsetTop of divI (inner) it returns me the top of divI in divM and not
the top of divI in the document? Have anyway to get this information?

Gratefull
Francisco
 
A

alu

Francisco said:
Hi all,

I have a div (divI) inner another div (divM), when i request the
offsetTop of divI (inner) it returns me the top of divI in divM and not
the top of divI in the document? Have anyway to get this information?

Gratefull
Francisco

If you want to continue using offsetTop,

document.getElementById("divM").offsetTop+document.getElementById("divI").of
fsetTop


you'll still get different results in different browsers.
-alu
 
F

Francisco

heave another way? because this page is a resultset interation and i
need to know it without knowing the another div offsetTop.
 
A

alu

Francisco said:
heave another way? because this page is a resultset interation and i
need to know it without knowing the another div offsetTop.


Post a real example, as it's impossible to tell how you've gone about
positioning them.
-alu
 
F

Francisco

an example...

<html>
<head>
</head>
<body>
<div id="divPrincipal" style="width:700px;border:1px #CFCFCF
solid;height:380;background-color:white;">
<div id="divCabecalho"
style="width:100%;height:85px;border-bottom:1px #CFCFCF
solid;">Header</div>
<div id="divConteudo"
style="width:100%;height:275px;padding:2px;">
<div id="MenuP">
<div class="menuPrincipal"
onmouseOver="MenuP0.style.top=this.offsetTop;
MenuP0.style.left=this.offsetLeft;MenuP0.style.display=''"
onmouseOut="MenuP0.style.display='none'">
<a href="#">File Menu</a>
</div>
</div>
<div id="MenuP0"
style="display:none; position:absolute;
background-color:#FBFBFB; border:1px #EBEBEB solid; padding:1px;"
onmouseover="this.style.display=''"
onmouseout="this.style.display='none'">
<div class="menuSecundario">
<a href="#">Option1</a>
</div>
</div>
</div>
</div>
</body>
</html>
 
A

alu

Francisco said:
an example...
<html>
<head>
</head>
<body>
<div id="divPrincipal" style="width:700px;border:1px #CFCFCF
solid;height:380;background-color:white;">
<div id="divCabecalho"
style="width:100%;height:85px;border-bottom:1px #CFCFCF
solid;">Header</div>
<div id="divConteudo"
style="width:100%;height:275px;padding:2px;">
<div id="MenuP">
<div class="menuPrincipal"
onmouseOver="MenuP0.style.top=this.offsetTop;
MenuP0.style.left=this.offsetLeft;MenuP0.style.display=''"
onmouseOut="MenuP0.style.display='none'">


-----------You have not defined MenuP0 ----
document.getElementById('MenuP0')-----


<a href="#">File Menu</a>
</div>
</div>
<div id="MenuP0"
style="display:none; position:absolute;
background-color:#FBFBFB; border:1px #EBEBEB solid; padding:1px;"
onmouseover="this.style.display=''"
onmouseout="this.style.display='none'">
<div class="menuSecundario">
<a href="#">Option1</a>
</div>
</div>
</div>
</div>
</body>
</html>
</html>


Without absolutely positioned divs, you would be forced to do a
quick google search, which would bring up
https://lists.latech.edu/pipermail/javascript/2004-January/006906.html

-alu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top