Question about iframes?
I have an iframe:
For ex.
Now when a link is clicked in this frame i want my whole page to go that page and not j开发者_运维技巧ust that frame.
How do i do it ?
Thanks
There are two options:
1st option: If you can edit the page in the frame, set all the links in that page to
target="_top"
So it should be like this
EXAMPLE.HTML
This is an example website.
This is an example <a target="_top" href="http://www.google.com">link</a>
And then the main webpage where you have the iframe.
<iframe src="example.html"></iframe>
and that should work fine.
Another way is to set all the links automatically using Javascript. This only works if the page you are loading is in the same domain as the main page.
<script language="Javascript">
function changeLinks(targ)
{
var links=targ.contentDocument.getElementsByTagName("a");
for(var i=0;i<links.length;i++)
{
links[i].target="_top";
}
}
Set the "target" attribute of the hyperlink to "_top".
Do you have control over where the links go in the content of the iframe?
if so, you can target="_parent" in the link in the iframe.
精彩评论