By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,773 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,773 IT Pros & Developers. It's quick & easy.

Q: location.href change & scrollBy problem

P: n/a
JF
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.location.href = "newhreflabel";
window.opener.scrollBy(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.document.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
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
JF <jf***@ics.muni.cz> wrote:
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.location.href = "newhreflabel";
window.opener.scrollBy(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.document.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?


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.location.href = "body.htm#myanchor";

To reload to another document, you can use:

window.opener.location.href = "otherdocument.htm";
or
window.opener.location.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.href could be called from 'body.htm' as well
as from 'contents.htm' as long as they reside on the same domain.

--
Bart
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.