How to Disable Right Click

It’s not really advisable because it makes life difficult for visitors who like to right-click links to open pages in new tabs and windows plus anything that can be done from the right-click menu can be done with short-cuts and menu bar items so disabling right-click doesn’t really achieve much; but if you really want to know how to do it… insert this script into your web page’s header:

<script language=JavaScript>
<!-- -->
var message = "Sorry my friend, right-click has been disabled";
function rtclickcheck(keyp){ if (navigator.appName == "Netscape" && keyp.which == 3){     alert(message); return false; }
if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) {     alert(message);     return false; } }
document.onmousedown = rtclickcheck;

Another way to “hide” your code is to put lots of carriage returns (hold down the “Enter” key) at the top of your webpage code before the declaration type. It doesn’t really hide you code but it does make the source code appear to be missing unless you scroll to the bottom of the source code view page.

Sharing is caring!

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x