Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable right click for Shadowbox.js

I'm currently using Shadowbox.js to my gallery and I want to disable the right click when the visitor views the image in full size. How can I accomplish this?

Thanks in advance.


1 Answers

You can do the following to specifically target Shadowbox.js and leave the context menu intact on the rest of the page.

jQuery 1.7+

$(function(){
    $('#sb-wrapper').on('contextmenu', function(){return false;});
});

jQuery 1.6

$(function(){
    $('#sb-wrapper').live('contextmenu', function(){return false;});
});

Native

//Should be executed as part of the window.onload method 
document.getElementById('sb-wrapper').oncontextmenu = function(){return false;}

Demo

Execute the Native statement in the Chrome's console on http://www.shadowbox-js.com/

like image 73
Brandon Boone Avatar answered Feb 26 '26 02:02

Brandon Boone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!