Tuesday, April 6, 2010

Disable Right-Click in Webpage Using Javascript

Here's a simple javascript snippet you can use to disable right-click in your web pages:



document.oncontextmenu = function() { 
    alert('Right-click is disabled.');
    return false
}


Just place the above code anywhere in your main javascript file or in the head part of the main page. You can also remove or change the alert if you don't want to notify the user.

No comments:

Post a Comment