Javascript to disable Right Click

This is an handy script to disable right click in webpages. Just put this script in between javascript tag and have right click disabled on your webpage.


     var message="Sorry, Right Click is disabled.";
   //To disable the right click on the page
    function click(e) 
    {
        if (document.all)
         {
            if (event.button == 2) 
            {
            alert(message);
            return false;
            }
         }
        if (document.layers) 
         {
            if (e.which == 3) 
            {
            alert(message);
            return false;
            }
         }
    }
    if (document.layers) 
    {
        document.captureEvents(Event.MOUSEDOWN);
    }
    document.onmousedown=click;

Thanks
A Rahim Khan

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: