gstackoverflow gstackoverflow - 1 year ago 97
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 ?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download