Jumping to anchor within a iFrame - without moving parent page

  • Thread starter Robert Mark Bram
  • Start date
R

Robert Mark Bram

Hi All,

We are using a scrolling iFrame to present a list of options to the
user within the main page with an anchor against each option. Depending
on the user actions, we jump to an anchor in the frame with code like
this:

theFrameSrc = theFrame.src;
theFrame.src = theFrameSrc + "#" + anchorName;

The issue is that when we jump to it, the parent document moves as well
i.e. the frame scrolls to bring the option to the top of the frame, but
then the main document scrolls to bring that option to the top of the
window.

Is there a way to turn off this second behaviour, so that only the
iFrame scrolls?

Any help would be most appreciated!

Rob
:)
 
G

Gérard Talbot

Robert Mark Bram a écrit :
Hi All,

We are using a scrolling iFrame to present a list of options to the
user within the main page with an anchor against each option. Depending
on the user actions, we jump to an anchor in the frame with code like
this:

theFrameSrc = theFrame.src;
theFrame.src = theFrameSrc + "#" + anchorName;

The issue is that when we jump to it, the parent document moves as well
i.e. the frame scrolls to bring the option to the top of the frame, but
then the main document scrolls to bring that option to the top of the
window.

Is there a way to turn off this second behaviour, so that only the
iFrame scrolls?

Any help would be most appreciated!

Rob
:)

Providing the url to the actual page being developed is always a good idea.

<a href="[IframeURL].html#anchorName" target="IframeName">Some option</a>

There is always the possibility of using scrollIntoView(false) to
prevent the scrolling.

Gérard
 

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

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top