Question

I'm using ThickBox for a lightbox and I need to check if the current page exists within a TB or not. How can I do this with jQuery?

Was it helpful?

Solution

Presumably your boxed page could check for a container. On the demo site, the container has the id TB_window. So in that example, you could do something like this:

if( $('selector-for-stuff-that-might-be-boxed').closest('#TB_window').size() ){
  // you're probably in a box
}

Note: if the point of this is to apply different styles to the boxed content, you can do that with just regular CSS by adding that ID to the CSS selector:

/* applies to non-boxed content */
.my-style { /*...*/ }


/* applies to boxed content */
#TB_window .my-style { /*...*/ }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top