开发者

How to Close Fancybox with a Link

I need the ability for Fancybox to be closed when a user clicks a link inside the fancybox.

I have tried:

href="javascript:$j.fn.fancybox.close();"

(note I am using jQuery with no conflict hence the $j) `

When I try it it does not work and I get an error in Firebug that says $j.fn.fancybox.close is not a function.

Note: I am using Fancy开发者_开发百科box version 1.3.4

Here is the script of the Fancybox:

<script type="text/javascript" >
    var $j = jQuery.noConflict();

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

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

    'padding' : 0
});

</script> 

HTML Code for Fancybox:

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

Any ideas how to get this to work properly?


Try calling $j.fancybox.close(); rather than $j.fn.fancybox.close();


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


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


This should work:

$.fancybox.close();


And if you are trying to close fancybox from inside an iframe try this:

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


Check this out.

How to open links from inframe outside of it?

Seems like the target="_top" does the job!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜