Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect the parent page from IFrame

Tags:

c#

asp.net

iframe

I am using an IFrame, and from this IFrame I want to redirect to another page.

Please tell me how to do this without any JavaScript, ie, no window.location.

Response.Redirect shows the page in the IFrame, but I want to show page as a main page.

like image 492
Waheed Avatar asked Jan 19 '10 09:01

Waheed


People also ask

How can I change parent URL in iframe?

1) click on images link in iframe changes Parent page, click on another iframe image link changes Parent to another page (see below). can you please post the code you're currently using, in addition to the link you provided? You need to name the parent and use the target attribute.

Does iframe support redirect?

Redirect the page containing your iframe embed The second option would be to redirect the page where you have your iframe embedded, known as the "parent" page. Modern browsers will prevent an iframe from changing the location of its parent page for security reasons.

How do I redirect a parent page in iframe?

parent. location. href = "http://www.example.com"; Will redirect the parent iframe.

How do I access iframe parent?

Once id of iframe is set, you can access iframe from inner document as shown below. var iframe = parent. document. getElementById(frameElement.id);


2 Answers

It will be a hazard if we can manipulate other frames/window withou using client-side scripts or user-invoked actions.

Here's a list of alternatives:

Javascript options:

window.top.location.href=theLocation; window.parent.location.href=theLocation; window.top.location.replace(theLocation); 

Non-javascript options:

<a href="theLocation" target="_top">Click here to continue</a>   <a href="theLocation" target="_parent">Click here to continue</a> 
like image 185
o.k.w Avatar answered Oct 05 '22 23:10

o.k.w


I used this code.

ClientScript.RegisterStartupScript(GetType(), "Load", "<script type='text/javascript'>window.parent.location.href = '../CentinelError.aspx'; </script>"); 

And it works.

like image 43
Waheed Avatar answered Oct 05 '22 21:10

Waheed