offsetTop

Discussion in 'Javascript' started by Francisco, Jul 15, 2005.

  1. Francisco

    Francisco Guest

    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
    Francisco, Jul 15, 2005
    #1
    1. Advertising

  2. Francisco

    alu Guest

    "Francisco" <> wrote

    > 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
    alu, Jul 15, 2005
    #2
    1. Advertising

  3. Francisco

    Francisco Guest

    heave another way? because this page is a resultset interation and i
    need to know it without knowing the another div offsetTop.
    Francisco, Jul 15, 2005
    #3
  4. Francisco

    alu Guest

    "Francisco" <> wrote
    > 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
    alu, Jul 15, 2005
    #4
  5. Francisco

    Francisco Guest

    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>
    Francisco, Jul 15, 2005
    #5
  6. Francisco

    alu Guest

    "Francisco" <> wrote
    > 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
    alu, Jul 15, 2005
    #6
  7. Francisco

    ASM Guest

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


    http://www.quirksmode.org/js/findpos.html

    --
    Stephane Moriaux et son [moins] vieux Mac
    ASM, Jul 18, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gernot Frisch

    TD .offsetTop not working in IE6

    Gernot Frisch, Apr 22, 2004, in forum: Javascript
    Replies:
    2
    Views:
    144
    Gernot Frisch
    Apr 23, 2004
  2. Markus Fischer
    Replies:
    3
    Views:
    137
    Markus Fischer
    Sep 8, 2004
Loading...

Share This Page