5416339
5416339

Reputation: 417

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 just that frame.

How do i do it ?

Thanks

Upvotes: 0

Views: 55

Answers (3)

Nareshkumar Rao
Nareshkumar Rao

Reputation: 105

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";
    }

}

Upvotes: 1

n8wrl
n8wrl

Reputation: 19765

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.

Upvotes: 0

David
David

Reputation: 34573

Set the "target" attribute of the hyperlink to "_top".

Upvotes: 0

Related Questions