A bit old stream, but ...
Actually, I suspect that the answer to the original question about how to close a window from inside is more related to the fact that the click event is not attached to the element. If the click event is attached in document.ready, the event will not be attached when fancybox creates a new window.
You need to reapply the click event after a new window. Probably the easiest way to do this is to use the onComplete function.
This works for me:
$(".popup").fancybox({ 'transitionIn' : 'fade', 'transitionOut' : 'elastic', 'speedIn' : 600, 'speedOut' : 400, 'overlayShow' : true, 'overlayColor' : '#000022', 'overlayOpacity' : 0.8, 'onComplete' : function(){$('.closer').click(function(){parent.$.fancybox.close();})} });
Actually, after a little thought, โlivelyโ rather than โclickโ or โbindโ may work just as well.
niccol May 12 '11 at 2:59 pm 2011-05-12 14:59
source share