Home > Can I disable right click on my website?

Q.Can I disable right click on my website?

Views: 2,092

You can. You may wish to disable right click on your website to prevent visitors from downloading files or images. Please note that this is not a foolproof method to prevent downloading, and this may impede the use of other right click functions such as Google Translate.

To disable right click on your whole website, navigate in your Shop Manager to MarketingSEO (Global). In the Header section, paste the following text:

<script type="text/javascript">
jQuery(function () {
jQuery('body').on('contextmenu copy', function () {
var message ="ENTER TEXT HERE";
if (message) {
alert(message);
}
return false;
});
});
</script>

Replace "ENTER TEXT HERE" with text you wish to display in a dialog box on attempting to right click. Leave blank if you do not wish any message to be displayed.

If you only wish to disable right click on images, paste the following text in the Header field instead of the above:

<script type="text/javascript">
jQuery(function () {
jQuery('body').on('contextmenu', 'img', function () {
var message ="ENTER TEXT HERE";
if (message) {
alert(message);
}
return false;
});
});
</script>

As with the previous code to disable right click sitewide, replace "ENTER TEXT HERE" with the dialog box text of your choice, or leave blank for no dialog box.

Notes:

Please be aware that if welcome page or custom pages are set to Do not import global CSS and JavaScript files, right click will remain enabled on these pages.

Last update: 20 Dec 2017 10:32