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>
<!-- http://www.spacegun.co.uk -->
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;
</script>

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.

Leave a Reply

All original content on these pages is fingerprinted and certified by Digiprove
Auto Rotating Ad Banner, No iFrame, No Page Refresh..And It’s Free!
Navigating The Linux Command Line
Loading

Invite Friends to ‘JournalXtra’

Supercharge your web design skills with JournalXtra

Buy me lunch!

I'm a cheap date. Where else can you buy lunch for a couple of dollars?

I accept Bitcoin too!

Categories

Dynamik Website Builder
WPMU DEV - The WordPress Experts
StudioPress Theme of the Month