View Full Version : Disable right click over specifik elements?

01-20-2006, 05:03 PM
Is it possible to dissable right click over specified elements but not over the entire document?.

PS. I wanna disable the right click cause I am using it to something else.

01-20-2006, 05:09 PM
it is possible, but generally a bad idea due to users wanting to keep the same functionality of their browser. They can always circumvent what you are doing by turning off javascript anyway.

There's a phrase that goes something like, "JavaScript should always be used to enhance, not inhibit a user's experience". I can't remember the exact wording but essentially in removing the right-click, you'd be inhibiting the user from using their natural menu systems.

hope this helps


01-20-2006, 10:00 PM
Decent web browsers ignore any attempt to disable the right mouse button. For the others theres always tohe enable right click bookmarklet to bring it back. http://javascript.about.com/library/blright.htm

01-21-2006, 07:44 PM
well now 2 have told me what I already knew that such a script could be disabled, but still no one has actually posted a script or a link to a script that actually achieved what I wanted.

01-21-2006, 07:47 PM
Its pointless. There is no real gain in doing what you want other than hindering the browsing experience of the user. http://www.dynamicdrive.com/dynamicindex9/noright2.htm

All it takes is some simple searching.

01-21-2006, 09:20 PM
There is no script that will disable the right mouse button in a decent web browser.

01-21-2006, 09:29 PM
i'd be curious to know exactly what you wish to do with the script. while the approach is looked down upon your application might warrent it... just explain it :)

01-21-2006, 11:18 PM
Here is the reason:

currently I am using one of those scripts that disable right clicking in the entire document, but I really only need to disable it over the lesser area that is the game board.

01-21-2006, 11:51 PM
ahh you see, that makes a lot of sense.

now let me ask you, do you need the right click to perform an alternate function, or you just don't want it at all?

01-22-2006, 07:42 AM
Yes you place flags with rigth click as you always have

01-22-2006, 08:41 AM

did you find what you needed or are you still looking?

01-22-2006, 09:31 AM
I would recommend allowing right click and shift+click to set mines, just in case they have their browser set to force contextmenu ability.

01-22-2006, 10:37 AM
I used JKD idea and now allow people to choose between either rigth click or shift+left click.

Thanks for the help to those that put an effort into it.

06-02-2009, 01:02 PM
How does one enable right click when it has been disabled by a website?

Philip M
06-02-2009, 01:30 PM
This is a very old thread and you should really start a new thread regarding your question.

Simply copy following script and put it into address bar of the browser. Right click will be enabled again.


which demonstrates the futility of no-right-click scripts.

Quizmaster: In nature, what invertebrate has a name which literally means "one hundred feet"?
Contestant: Giraffe