2013-05-01 61 views
3

我想关闭fancyBox,然后立即打开新的花式框。但它没有发生。多个jquery fancyBox

实际发生的情况是,它首先显示警报,然后关闭花式框。

function OpenWindowNew_(type, URL, Namee) {     
    parent.$.fancybox.close(); 
    alert(); 
    $.fancybox.open({ 
     href: URL, 
     type: 'iframe', 
     padding: 5 
    }); 
} 
+1

[使用的fancybox 2版的可能重复 - 闭幕时第二个fancybox重新打开第一个fancybox而不是简单地关闭](http://stackoverflow.com/questions/10973380/using-fancybox-version-2-when-closing-2nd-fancybox-reopen-first-fancybox-inste) – JFK 2013-05-01 06:49:20

回答

1

下面是一个代码片段你

脚本:

<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>