How to Disable Right Click on Website

Learn How to disable right click menu on any website in this tutorial. There are some people on the web who scrape your content and use it on their own website without taking permission. In such cases they don’t give credit to original author and also they don’t care who is the original source. Such type of plagiarists are hard to deal with as they’re going to deny every form of communication to take down the content. In such a case you should consider protecting your content and feeds from such scrapers.

In this tutorial we’ll see how to disable the the right click browser specific menu. As this JavaScript is taken from dynamic drive, credit of this code snippet goes to renigade (dynamic drive).

Disable Right Click on Static HTML Sites

For static sites with limited web pages should add the following code inside the html page. Make sure you add this code before < / body > tag of the html page.

<script language=JavaScript>
<!--
var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
 
document.oncontextmenu=new Function("return false")
// --> 
</script>

Disable Right Click on WordPress Blog

In case of wordpress you can either edit header.php or footer.php of your theme OR you can use text widget in sidebar or footer to add this code. If you change theme, just add the widget back again to enable the script or else you can again modify the footer.php or header.php of theme.

Adding Javascript Code in Text Widget of WordPress

Disable Right Click on Blogger Blog

You can add HTML widget in sidebar and then add the above code. This will eliminate the need to updating the code if you change theme. This sidebar usually remains consistent even after theme changes so you’ll definitely benefit by adding the code in html widget.

Tumblr, WordPress.com, Joomla and Drupal

  • WordPress.com allows you to use add TEXT widget in sidebar which you can use to add this javascript snippet.
  • Tumblr is an online CMS and in order to make the changes you have to edit the theme of tumblr. So after every theme changes you have to add this javascript snippet into theme.
  • Joomla and Drupal has theme and templates feature which you can use to edit the themes. Adding this javascript snippet in your theme is very easy if you’re already using such a complicated CMS like drupal (or joomla).

If you’re using any other content management system like textpattern, expression engine etc. then you have to ask for help in respective community forums.