I want, if possible, to open fancybox as a child of the parent using an iframe.
Is it possible to open an iframe (built with fancybox) and do a browser verification, I opened it with window.open so that functions like window.close() or window.opener.location.reload() still work?
The fancybox code is simple:
$("#custom_alert").fancybox({ 'width' : w, 'height' : h, 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'type' : 'iframe', //'scrolling' : 'no' }).trigger('click');
EDIT: I can't use features like:
function closePopup(){ window.close(); if(parent.jQuery().fancybox) { parent.jQuery.fancybox.close(); } }
I MUST use the window.close () function.
You can also fix the problem to tell me why I cannot rewrite the close function, as was the case with a warning or confirmation.
EDIT 2: Thanks to Raohmaru and JFK, after seeing the fiddle, I did the function I needed, but a strange thing (for me) happens:
Working code, if someone else needs it:
(function() { var proxied = window.close; window.close = function() { if(parent.jQuery().fancybox) { parent.jQuery.fancybox.close(); } else return proxied.apply(this, arguments); }; })();
This works for both fancybox and window.open cases.
My problem was this: I include some .js files in the index:
overwrites fancybox pack general scripts
If I put this function in shared scripts, it works fine, but if I put it in rewritable js (where it should be), it will not work (no console errors, just nothing happens). I tried replacing the positions on the tabs, but no luck.
That's why I couldn't get it to work from the first place, because I always included it in overwrites .js.