Open a a fancy box from within another fancybox

1,875 views
Skip to first unread message

Dale Larsen

unread,
Apr 24, 2009, 1:58:18 PM4/24/09
to fancybox
Before I download and build out a fancy box I want to know if anybody
knows the following:

Can I open a new fancy box from within a fancy box?

-- I need this because we need to create a close confirmation when you
try to close your fancybox, so I need a fancy box to open confirming
that you want to close the main fancy box. I also need this because I
have content in the fancy box including a link to open a video from
the fancy box, and I need to open the video in a new fancy box over
the other one that is still open.

Thanks!

~Dale

JFK

unread,
Apr 24, 2009, 2:29:24 PM4/24/09
to fancybox
yes sure you can

JFK

unread,
Apr 24, 2009, 2:45:28 PM4/24/09
to fancybox
the best way to prove it is opening the fancybox homepage in a
fancybox and play the examples "nested"

the script:
$(document).ready(function() {
$("a#nested").fancybox({
'frameWidth': 900, 'frameHeight': 450, 'hideOnContentClick':
false
});
});

the html:
<a id="nested" href="http://fancy.klade.lv/example?iframe" >OPEN
fancybox home page</a>

Dale Larsen

unread,
Apr 27, 2009, 12:09:28 PM4/27/09
to fancybox
Thank you! However, I tested it out and it doesn't work.

I don't mean open another one that is in an iframe. I mean to open
another fancybox popup while another is still opened on the very same
page. Meaning when I have one opened using ajax content, and then
clicking a link (that is on my opened popup) to show a video, I need a
video to open in another fancybox popup, over top of the already
opened one.

I don't want to have to duplicate your script to allow for mulitiple
popups at once but if there is no alternative... I will need to.

Do you know of a work around or how this is possible?

Thanks!

Dale
Message has been deleted

Dale Larsen

unread,
Apr 27, 2009, 4:30:03 PM4/27/09
to fancybox
To explain more, when I open a new one it takes over the one already
opened instead of just opening an additional one on top of it.
I need a new one opened on top of the one already opened and then when
you close the new one it needs to not close the first popup.

Do you know a quick fix or will this be available in a future release?

Thanks! I think the lightbox script is one of the best!!!

Dale

Nate

unread,
Apr 28, 2009, 1:50:23 PM4/28/09
to fancybox
I do believe that this is possible, but not very easy.
it would take a good rewrite of the script.
This limit has more to do with the HTML then the fancybox.

In HTML each document window is its own entity with no knowledge of
other windows.
essentially you want each window to be aware of the other windows.

In order to do that you must have a "hook" via JS for every window,
AND every window must have its own JS file that tells it which file it
is and references the other windows JS hooks.

There is no way the developer can do this for you, it is a custom
solution based on your needs.
And a lot of work, if you want to do it have fun, and feel free to
post the results here!

It is possible to open a fancybox in a fancybox, just make the first
one and iframe and include the fancybox script in the iframe source.
Just make sure your second fancybox is smaller because it is now
limited by the size of the window, which is the size of the open
fancybox.
You may be able to use it like this and use the target command, or JS
equivalent, to reference the root window, and exit both windows.

Dale Larsen

unread,
Apr 30, 2009, 5:09:42 PM4/30/09
to fancybox
To get this to work I had to rewrite the script. For now I just
duplicated the main js file and renamed the functions so I could call
a new box.
Reply all
Reply to author
Forward
0 new messages