Disabling right-click with Featherlight.js

140 views Asked by At

I am using Featherlight version 1.5.0 in my design. I can disable the right-click on the thumbnail images with this snippet of JavaScript:

<script type="text/javascript">
  $('img').bind('contextmenu', function(e) {
    return false;
  }); 
</script>

But this doesn't work with link images, which pops up when the thumbnail is clicked. Is there anyway that right-click can be disabled on the link images?

1

There are 1 answers

1
Purvik Dhorajiya On

$('img').bind('contextmenu', function(e) {
    return false;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h3>Gallery</h3>
<div data-featherlight-gallery data-featherlight-filter="a">
  <a href="http://farm8.staticflickr.com/7070/6874560581_dc2b407cc0_b.jpg"><img src="http://farm8.staticflickr.com/7070/6874560581_dc2b407cc0_q.jpg" /></a>
  <a href="http://farm5.staticflickr.com/4005/4400559493_3403152632_o.jpg"><img src="http://farm5.staticflickr.com/4005/4400559493_f652202d1b_q.jpg" /></a>
  <a href="http://farm1.staticflickr.com/174/396673914_be9d1312b1_o.jpg"><img src="http://farm1.staticflickr.com/174/396673914_be9d1312b1_q.jpg" /></a>
</div>

Would you please check above snippet? It's working fine with your code.