Test if current page is inside a shadowbox? (so i can close the shadowbox and reopen that page in t

Posted by Max Williams on Stack Overflow See other posts from Stack Overflow or by Max Williams
Published on 2010-05-26T10:20:56Z Indexed on 2010/05/26 12:41 UTC
Read the original article Hit count: 294

Filed under:
|

Hi all

I have a couple of pages in my site which open in a shadowbox window rather than the main window. My problem is that if the user session expires, then the user clicks on one of the links that open in a shadowbox, they are redirected to the login page INSIDE THE SHADOWBOX, which i don't want. I've been trying to think of the best way to handle this - one way i thought of, which seems a bit clumsy tbh, was on the login page to test if we're in a shadowbox, and if we are then close it and redirect the parent window to the login page.

a) does this seem like a sensible plan? I added the following to my login page, which works:

  $(document).ready(function(){
    if(window.parent.location != window.location){
      window.parent.location.href = window.location;
    }
  }

but i have to wait for the shadowbox to finish loading the page and then redirect. So it's working but like i say a bit clumsy. Is there a nicer way?

grateful for any advice - max

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about shadowbox