how to redirect parent page from iframe page_load?

S

Sheryl Landon

Hi, I'm having a similar issue as the poster Mike whose message I copied
below... I have a page with an iframe... when I discover that the session
state is no longer valid in the page inside the iframe, I want to redirect
the parent page to a login page. Can anyone help me?

Thanks,
Sheryl


How can an IFrame's aspx page force a server-side redirect on its parent
page? Typically, an IFrame's client-side javascript specifies '_top' to
change the parent page...
window.open('default.aspx?SMID=18', '_top', '', false);
 
R

Robbe Morris [C# MVP]

Stick this at the top of all your non-iframe pages and
call it in the body onload event.

If your page in an iframe attempts to redirect to one of
the non-frame pages, it will break out of the iframe.

function TimeOutRedirect()
{

try
{
if (self.parent.frames.length != 0)
self.parent.location=document.location;
}
catch (Exception) {}

}

--
2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx
 
S

Sheryl Landon

Hey, that's way cool! the first thing I've seen that worked in my
situation! And I've tried quite a few "solutions" out there! Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top