On the page there is a link http: // my site / index.php? Id = 20 when you click on it, a fancybox pops up with an add form, how to prevent this window from opening through -> right mouse button -> open a link in a new window? If this is done, there will be a bare, ugly page on which nothing but a form will appear.

  • you can change html by making the button not through <a> , but through <button> - right-click on it does not work - lexxl
  • @lexxl can be more specific, I have never called fancybox through a button, but still it doesn’t work because the link is textual, the button will not be sculpted there. - Winteriscoming 2:12 pm

1 answer 1

The element that opens fancybox's popup does not have to be a link. You can generally open the popup anytime, calling it directly.

Look at the code below: instead of a link, I made a “button” with a regular div with a picture inside. And in its click handler function, I open the pop-up fancybox.

 $(".fancybox").on('click', function(){ $.fancybox({ href: $(this).data('href') }); }); 
 <link href="http://fancyapps.com/fancybox/source/jquery.fancybox.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="http://fancyapps.com/fancybox/source/jquery.fancybox.js"></script> <div class="fancybox" data-href="http://fancyapps.com/fancybox/demo/1_b.jpg"><img src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt=""/></div>