Portal Home > Knowledgebase > How To's and more > How to Disable Right Click on Your Web Pages

How to Disable Right Click on Your Web Pages

To prevent someone from using the right mouse button on your site, paste the following code in your web page just above the body tag:


<SCRIPT language="JavaScript">
function click() {
if (event.button==2) {
alert('Copyright © 2003 YOURSITE.COM');

// -->

Make sure you change YOURSITE.COM to what text you want shown.

Our you could do it without loads of code. And you can write it yourself. Put this in your body tag: 
oncontextmenu="return false"

<body oncontextmenu="return false">

You can also disable select and drag like this:

<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">


Here's a little bit more powerful script.


<script language=JavaScript>

var message="Function Disabled";
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
return false;
else if (document.layers||document.getElementById) {
if (e.which == 3) {
return false;
if (document.layers) {
// -->

Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
File Extensions (Views: 316)