Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Redirect Parent URL from within iframe

New Here ,
Dec 26, 2008 Dec 26, 2008
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!
TOPICS
How to , Server side applications
8.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 26, 2008 Dec 26, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 26, 2008 Dec 26, 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 26, 2008 Dec 26, 2008
LATEST
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines