I want to close fancyBox then immediately open new fancy box. But it didn't happen.
What actually happens is, it first displays alert and then closes the fancy boxes.
function OpenWindowNew_(type, URL, Namee) {
parent.$.fancybox.close();
alert();
$.fancybox.open({
href: URL,
type: 'iframe',
padding: 5
});
}
Here is an code snippet for you
Script :
<script>
$(document).ready(function()
{
$("a#MyBox1").fancybox({ 'hideOnContentClick': false, 'frameWidth': 400, 'frameHeight': 400,
callbackOnClose: function() { window.setTimeout('open2()',100); }
}).trigger('click');
});
function open2(){
$("a#MyBox2").fancybox().trigger('click');
}
</script>
HTML :
<div id="firstFancybox" style="display:none">
<p>I'm the first Fancybox!</p>
<a href="#" onclick="open2();">Close first Fancybox</a>
</div>
<a id="MyBox1" href="#firstFancybox"><!--for first fancy box--></a>
<div id="secondFancybox" style="display:none">
<p>I'm the Second Fancybox!</p>
</div>
<a id="MyBox2" href="#secondFancybox"><!--for second fancy box--></a>