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.
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.
I think there is no way to do it without JS. Browser will treat every redirect from server in the iframe. You have to 'tell' it to reload whole window using JavaScript.
has to be javascript as far as i know.
self.parent.location='http://'
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>
I used this code.
ClientScript.RegisterStartupScript(GetType(), "Load", "<script type='text/javascript'>window.parent.location.href = '../CentinelError.aspx'; </script>");
And it works.
Well, this is really a hack, but you could define Parent-Frame as default target:
<base target="_parent">
As this will apply to all your links in the iframe, this may not be a satisfying solution ;-)
Like all others have pointed out, you can't do it without using JavaScript. However, on the server side you can emit the necessary JavaScript so that the page gets redirected to the target location as soon as it loads within the iframe.