简体   繁体   中英

Disabling right-click with Featherlight.js

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?

 $('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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM