How to close Fancybox using a link

I need Fancybox to close when the user clicks a link inside fancybox.

I tried:
href="javascript:$j.fn.fancybox.close();"
(note that I'm using jQuery without conflict, therefore, $ j) `

When I try, 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 Fancybox version 1.3.4

Here is the Fancybox script:

 <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 make this work correctly?

+4
source share
4 answers

Try calling $j.fancybox.close(); , not $j.fn.fancybox.close();

+12
source
 <a href="javascript:void(0);" onclick="$.fancybox.close();">Close</a> 
+11
source
 <a href="" onclick="window.parent.parent.location.reload();">Close this</a> 
0
source

Check this.

How to open links from the outside world?

target="_top" seems to do the job!

-1
source

All Articles