Skip to main content
Participating Frequently
December 27, 2008
Question

Redirect Parent URL from within iframe

  • December 27, 2008
  • 3 replies
  • 8773 views
Hi - I have an iframe that contains a series of links ... and when the user clicks on one of the links within the iframe, I want the parent page's URL to be redirected to a particular URL.

Right now, if I just use the standard <a href="target URL">Text</a> for the link, it brings up the redirect JUST INSIDE the iframe ... but I want the parent page that contains the iframe to change to the target URL.

It is like I need to embed the statement:
************
<script language='Javascript' type='text/Javascript'>
window.location = "target URL";
</script>
************
inside the link - but I am not sure of the best or most proper way to do that.

Any suggestions? [I tried to do a SEARCH on my subject topic, and it generates some odd forum error message.] Thanks!
This topic has been closed for replies.

3 replies

Participating Frequently
December 27, 2008
Both the iframe and the parent page are on the same server - they are different pages of the same website. [The iframe is an index to a subsection of the site.]

The following seems to work - where I use this style of call for the various URLs in the iframe (which is an index to various other pages within the site):

<a href="URL to appear in parent browser" target="_parent">URL Text Identifier</a>

So it appears I do not need to add a

window.parent.location = "parent URL";
or
window.location = "target URL";

anywhere. Thanks!

or
Inspiring
December 27, 2008
Michael White wrote:

> Remember the "same origin policy", which means you can use js only to
> manipulate data from the same origin (same server).
> Mick


You should be able to do something like:

<a href="#" onclick="parent.location='pageinsamedomain.html'">

Mick
Inspiring
December 27, 2008
MLBdesigner wrote:
> Hi - I have an iframe that contains a series of links ... and when the user
> clicks on one of the links within the iframe, I want the parent page's URL to
> be redirected to a particular URL.
>
> Right now, if I just use the standard <a href="target URL">Text</a> for the
> link, it brings up the redirect JUST INSIDE the iframe ... but I want the
> parent page that contains the iframe to change to the target URL.
>
> It is like I need to embed the statement:
> ************
> <script language='Javascript' type='text/Javascript'>
> window.location = "target URL";
> </script>
> ************
> inside the link - but I am not sure of the best or most proper way to do that.
>
> Any suggestions? [I tried to do a SEARCH on my subject topic, and it
> generates some odd forum error message.] Thanks!
>
Remember the "same origin policy", which means you can use js only to
manipulate data from the same origin (same server).
Mick