views:

176

answers:

2

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

A: 

Use isOpen().

http://www.shadowbox-js.com/api.html

Try this.link.baseURI to see if that is the same as window.location if you want to access the browser location inside the shadowbox.

Kalyan M
Thanks Kalyan, but that only works in the parent window. It *doesn't* work when you call it in the page which is loaded inside the shadowbox.
Max Williams
Try the updated answer.
Kalyan M
thanks. is that effectively the same as "window.parent.location" like i do in my code above?
Max Williams
A: 

Try this on the login page:

var Shadowbox = window.parent.Shadowbox;

Then check to see if Shadowbox is undefined.

Jason