gstackoverflow gstackoverflow - 20 days ago 4
Javascript Question

fancybox opens in new tab

I have following html:

<a href="createCompany/getOriginalImage/1" class="fancy_image"><img id="right_tab_image" src="createCompany/getSmallThumbnail/1" alt=""></a>

And following code executes(tested in debug) when page loads:

type : 'image',
openEffect : 'none',
closeEffect : 'none'

and to the the page include following sources:

enter image description here

But when I click on href image opens but in another tab.

What did I forget ?


An imitation of the supplied code seems to work:


<a class="fancybox" href=""
<!-- Note that FancyBox ignores this width styling -->
<img src="" alt="" /><br>
<b>Click to trigger Fancybox</b></div>


$(document).ready(function () {
       padding: 0,
       type        : 'image',
       openEffect  : 'none',
       closeEffect : 'none'

See this demo.

So things you should try to get it working:

  1. Use the latest version of jQuery and the latest version of fancybox. Sometimes there are problems with the versions.
  2. Make sure that fancybox.js is actually loaded
  3. Specify your image links in the full http://.. format

I think if you follow all these points, it'll work. Otherwise, check if any of the other plugins cause problems with fancybox.