C# – Redirect the parent page from IFrame

asp.netciframe

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.

Best Answer

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>