Justin John
Justin John

Reputation: 9615

How to make right click of mouse to be pure dead?

Make right click of mouse to be pure dead. Even editing of javascript or anything else, can't allow right click access.

After disable the right click by something like below

window.oncontextmenu = function () {
   return false;
}

Still users can re-Enable the right click access by

javascript:void(document.oncontextmenu=null)

Is there any way to block right click access completely?

Upvotes: 0

Views: 306

Answers (3)

Ankur
Ankur

Reputation: 12774

No, You can't and you shouldn't, as user would be really pissed if somehow you are able to achieve it... Browsers are created so as to be as user friendly as possible and by forcefully disabling right click you are taking that right away from the user, which no browser would allow you to do.

Upvotes: 1

StaticVariable
StaticVariable

Reputation: 5283

You cannot do this completely.Javascript is a client side scripting language If user has disabled the javascript than he/she will be able to click .You should be user friendly

But if you want to do so use this

​document.onclick = function(e) 
 {
   if( e.which== 3 )
       {
         e.preventDefault();
              //or 
         return false;
       };​
 }

Upvotes: 2

Chaitanya
Chaitanya

Reputation: 5293

I don't think you can do this. This is running on the user's machine. The user can always change it to get what he wants.

I am guessing you want to do this to prevent him/her from doing a view source. But remember, they can just load it in chrome and use the Tools -> Developer tools option and see your source code anyway. And you really really can't disable the user's browser controls. :-)

Upvotes: 2

Related Questions