Forum Moderators: open
I have a parent page that contains an iframe. I have the following #Top link in the iframe page:
<a href="#top"><b>Back to top</b></a>
The problem is that this jumps to the top of the iframe page whereas I want it to jump to the top of the parent page.
any help would be most welcome...
This question was looked at in this thread: http://www.webmasterworld.com/forum21/8088.htm [webmasterworld.com]
You basically have to use a script, something like:
<a href="#" onclick="parent.location.href=parent.location.href+'#top';return false">Try me!</a>
The thing to watch with this is that it will try to append #top to the href, which could mean multiple #top's! So, better would be to use the actual URL of the page:
<a href="#" onclick="parent.location.href='parentURL.html#top';return false">Try me!</a>
You could use some javascript to scroll the page straight to the named anchor... But this automatic scrolling can cuase anger and confusion in users!
[edited by: BlobFisk at 9:18 am (utc) on Feb. 7, 2008]
I need to take this a step further:
In my iframe, i have an image which has a hotspot that loads a different page into the iframe:
<img src="image1.gif" name="Image1" border="0" usemap="#Map" id="Image1" />
<map name="Map" id="Map">
<area shape="rect" coords="370,2,437,23" href="iframe2.html" />
</map>
What I need is for iframe2.html to load in the iframe AND to jump to #Top on the parent page.
I hope this makes sense!
thanks again.