spyderman4g63
spyderman4g63

Reputation: 4309

Scroll to top of parent frame on iframe change?

Is it possible to scroll(0,0) to the top of the parent page when the user browses in an iframe? For example, we have an iframe that is the entire height of the page with search results. When you click the next page button in the iframe, the focus stays at the bottom of the page.

I'm not even sure if it's possible to detect this. The iframe src value doesn't actually change.

P.S. I don't know why this site must use an iframe, but IE6 is the standard browser so I didn't ask questions.

Upvotes: 18

Views: 55091

Answers (3)

Erwin Wessels
Erwin Wessels

Reputation: 3093

As an alternative, you can have the iframe ask the parent frame to scroll to the top with

parent.scrollTo(0,0);

I haven't researched the official browser support for it, but it works in IE9, FF10, Chrome 17 and Safari 5.1.

Upvotes: 9

TomGro
TomGro

Reputation: 21

<iframe onload="parent.location= 'http://mysite.com/page.html#nameofdivonthetopofpage';" ... 

Upvotes: 2

spyderman4g63
spyderman4g63

Reputation: 4309

Actually, the onload event does appear to work when navigating within an iframe.

<iframe src="http://mysite.com" height="2392px" width="100%" name="searchFrame" onload="scroll(0,0);"></iframe>

Upvotes: 28

Related Questions