Posts Tagged ‘ Disable Right Click ’

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