Q: location.href change & scrollBy problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JF

    #1

    Q: location.href change & scrollBy problem

    Hi,

    I need to change the location of the parent window and after
    that scroll a little bit (because of "position:fixed " css buttons,
    which obscure the title).

    I have
    window.opener.l ocation.href = "newhreflab el";
    window.opener.s crollBy(0, -25);

    The newhreflabel may point to the same document or load
    a new one (another chapter).

    There is a problem is with timing, T think I need to
    serialize those two instructions.

    However, the window.opener.d ocument.onload does not seem to
    be trigered by href change. Is there any other way how to
    do it - or I have ti all wrong?

    Thanks
    Josef
  • Bart Van der Donck

    #2
    Re: Q: location.href change & scrollBy problem

    JF <jfeit@ics.muni .cz> wrote:
    [color=blue]
    > I need to change the location of the parent window and after
    > that scroll a little bit (because of "position:fixed " css buttons,
    > which obscure the title).
    > I have
    > window.opener.l ocation.href = "newhreflab el";
    > window.opener.s crollBy(0, -25);
    > The newhreflabel may point to the same document or load
    > a new one (another chapter).
    > There is a problem is with timing, T think I need to
    > serialize those two instructions.
    > However, the window.opener.d ocument.onload does not seem to
    > be trigered by href change. Is there any other way how to
    > do it - or I have ti all wrong?[/color]

    One approach could be to use anchors in your documents.

    In your 'body.htm' file:

    <a name="myanchor" >...</a>

    Then in your 'contents.htm' file:

    window.opener.l ocation.href = "body.htm#myanc hor";

    To reload to another document, you can use:

    window.opener.l ocation.href = "otherdocument. htm";
    or
    window.opener.l ocation.href = "otherdocument. htm#otheranchor ";

    It 's not strictly necessary (though maybe better practice) that this
    code goes inside <body onLoad="...">. Just putting it in a <script>
    section should do it as well.

    A change of XXX.location.hr ef could be called from 'body.htm' as well
    as from 'contents.htm' as long as they reside on the same domain.

    --
    Bart

    Comment

    Working...