如何通过链接关闭Fancybox

4
我需要在用户点击Fancybox内的链接时关闭Fancybox。
我已经尝试过: href="javascript:$j.fn.fancybox.close();" (注意,我正在使用jQuery并且没有冲突,因此是$j)
当我尝试时,它不起作用,并且在Firebug中出现一个错误,其中显示“$j.fn.fancybox.close不是一个函数”。
请注意:我正在使用Fancybox版本1.3.4
以下是Fancybox的脚本:
<script type="text/javascript" >
    var $j = jQuery.noConflict();

    $j(document).ready(function(){

      $j("#start").fancybox({

    'padding' : 0
});

</script> 

Fancybox的HTML代码:

<div class="hide">
    <img src="/Images/skin/spacer1x1.png" onload="$j('#start').trigger('click');" />  
<a href="#welcome" id="start"></a>
    <img style="width:700px; height:600px;" id="welcome" usemap="#Map" alt="PLEASE VIEW PAGE WITH IMAGES ON" src="/Images/start/start.png" />
    <map id="Map" name="Map">
    <area alt="See Message Examples" href="/artistphotos/" coords="29,431,301,465" shape="rect" />
    <area alt="Enter Site" href="javascript:$j.fn.fancybox.close();" coords="436,433,567,464" shape="rect" />
    </map>
</div> 

有什么办法可以使这个正常工作?
5个回答

13

尝试调用$j.fancybox.close();而不是$j.fn.fancybox.close();


12
<a href="javascript:void(0);" onclick="$.fancybox.close();">Close</a>

0
<a href="" onclick="window.parent.parent.location.reload();">Close this</a>

0

这应该可以工作:

$.fancybox.close();


如果您正在尝试从 iframe 中关闭 fancybox,请尝试以下方法:

window.parent.$.fancybox.close();


-1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接