Click to See Complete Forum and Search --> : target 2 documents with <a href>


seanpaul
10-09-2008, 11:37 AM
Hi, I need to target and I-frame and the containing document with 1 <a> element. Is this possible in HTML or do I need JavaScript?

thanks

Fang
10-10-2008, 02:48 AM
If the containing document changes the iframe no longer exists.

seanpaul
10-10-2008, 12:20 PM
Actually, I want the web site to scroll to the top of the containing document, not the top of of the Iframe. Though, the link I am using is inside the Iframe. How do I target the containing document, and the Iframe?

opifex
10-10-2008, 02:38 PM
<a href="http://site.co/containingdoc.html#">top</a>

would be the most certain way. if the content of the iframe is in the same domain you don't need the "http://site.co"

but you have to know where the page in the iframe is being displayed.

seanpaul
10-10-2008, 03:02 PM
Hi
Here is a sample <a href> that changes the Iframe and brings the entire site to top of the window:<a class="MenuBarItemSubmenu" href="aboutUs.html#top" onClick="top.location.href='#top'"; target="mainBody">

thanks for helping me think this through

donatello
10-11-2008, 05:15 AM
There are two ways to understand your question...

If the iframe is lower on the page than the link and you want to scroll to the iFrame, then you would just use the anchor tag... put it just above the iframe like this:
<a name="iframe"></a>
Then call it when you click to have the page scroll down to the top of the iframe.

If you have control over the document you are putting in the iframe, you can just put an anchor tag inside of that. Then you can go to anyplace on the page you like.