how to redirect parent page from iframe page_load?

Discussion in 'ASP .Net' started by Sheryl Landon, Apr 28, 2005.

  1. 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


     
    Sheryl Landon, Apr 28, 2005
    #1
    1. Advertisements

  2. 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
     
    Robbe Morris [C# MVP], Apr 28, 2005
    #2
    1. Advertisements

  3. 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!
     
    Sheryl Landon, Apr 28, 2005
    #3
  4. Sheryl Landon

    raygberg

    Joined:
    Aug 5, 2010
    Messages:
    1
    Likes Received:
    0
    Hello:

    I was wondering if this solution would also work in Firefox 3.6? I realize that it's been 5 years since the above solution was posted. It works in IE 7.

    Ray G.
     
    raygberg, Aug 5, 2010
    #4
  5. Sheryl Landon

    sateswar

    Joined:
    Feb 27, 2012
    Messages:
    1
    Likes Received:
    0
    Thank you!

    Thank you! It worked for me on Chrome, Firefox and IE.





     
    sateswar, Feb 27, 2012
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.