determining if in SB window

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

determining if in SB window

otheroom
Is there a way through javascript or PHP for a page served up in a SB iframe to determine if it's being displayed in a SB window or not?

I was using the PHP $_SERVER['HTTP_REFERER'] in the iframe PHP page to see if it was invoked by an link outside of the domain. In that case I reload the page page that contains the SB link and have it automatically open a SB window.

A problem with this arises when the user has http_referer blocked or there's a firewall preventing that data from being sent.
Reply | Threaded
Open this post in threaded view
|

Re: determining if in SB window

Wizzud
You could try this:
var sboxed = window.name && window.name == 'sb-content';
The probability of your page being opened into a window named 'sb-content' by anything other than Shadowbox is quite low.
If you want to make absolutely sure, you could add a self v. parent test...
var sboxed = window.self != window.parent && window.name && window.name == 'sb-content';
What this won't do is tell you whether the parent is on or off domain - ie. yours or someone elses. Also, this is specific to v3.0b of Shadowbox; earlier versions used a different naming convention.

Combine literacy with curiosity and a whole world of information opens up to you
Reply | Threaded
Open this post in threaded view
|

Re: determining if in SB window

otheroom
I'm still using SB2 and based on your tips I've found that using:

window.name != 'shadowbox_content'

will do the trick nicely.

Thanks.