3

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
     });
 }
Rajneesh Gaikwad
  • 1,193
  • 2
  • 14
  • 30
  • 1
    possible duplicate of [Using Fancybox version 2 - When Closing 2nd fancybox reopen first fancybox instead of simply closing](http://stackoverflow.com/questions/10973380/using-fancybox-version-2-when-closing-2nd-fancybox-reopen-first-fancybox-inste) – JFK May 01 '13 at 06:49

1 Answers1

1

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>