views:

318

answers:

4

Hi. This question isn't about popping up an iframe inside a Lightbox; rather, it's about an iframe on a page that can launch its own Lightbox-style box in the page that contains that iframe. I'm thinking this can't be possible, because the iframe contains the contents of the other URL and whatever Lightbox that URL launches has to fit within the iframe. Thanks.

+1  A: 

If both sites belong to the same domain you can add the JS of the lightbox to the main frame and call the function inside the iframe using ´parent.function´

Javier Parra
Thanks, Javier. Unfortunately, the iframe site will be a remote URL.
Alex
If you have access to the remote URL you can set up some sort of AJAX listener, the iframe can post to the server a 'lightbox request' and when the parent picks it up show it.If you don't have control over the parent frame, there's no way, that's what it's designed for.
Javier Parra
+2  A: 

It is not possible for the <iframe> to interact with its parent frame if the two frames are on different domains.

SLaks
So if the iframe pops up a Lightbox on its own (no script interaction with parent page), the box has to fit within the iframe's dimensions or it's a no-go?
Alex
@Alex: correct.
SLaks
Weel, it's not impossible. You can interact with each other using a server in between via AJAX.Of course you need access to both frames.
Javier Parra
+1  A: 

Try looking at fancybox. I know that supports iframes, and I always use it over Lightbox, much more customisable. I am pretty sure it can deal with nested iframes, however I could be wrong. Worth a try nether the less.

Can display images, HTML elements, SWF movies, Iframes and also Ajax requests

There are examples on the bottom of the page: http://fancybox.net/

danixd
Thanks, danixd. I've used Fancybox but I'm not trying to show an iframe inside a Lightbox; rather, I need to have a Lightbox/Fancybox pop up out of the iframe. From what I'm discovering, that's not possible.
Alex
+1  A: 

I don't know if it's around anywhere online, but i saw Facebook give a presentation about injecting an iframe into other sites to circumvent such problems with cross-site issues. Worth a look.

John