Answer the question
In order to leave comments, you need to log in
Is it possible to remove a browser context menu item using JavaScript?
Greetings
We are all familiar with the browser context menu - the menu that appears when you click the right mouse button. This menu has different options: copy, save, back, view code, etc. Can JavaScript remove some menu items or make them inactive for all users visiting the page with this JS? If yes, then how? Concrete examples or ready-made scripts are welcome.
Answer the question
In order to leave comments, you need to log in
You can't change this context menu just like that. In the same chrome (for example), you need the appropriate rights to work with it . They can be given to a browser extension, but not to a simple page. The contextmenu attribute added in html5 only allows you to add your own items there, but not delete them. Yes, and it only works in Firefox ( example ). You only have the option proposed by Dmitry - to disable this menu and create your own. But nothing will stop a curious user from looking at your code or the resources you upload.
PS: From the mere thought that the page will begin to change the behavior of my browser in the direction of reducing functionality, there is a desire to take the keyboard and knock the author on the head) Or write a script that intercepts the interception of my context menu and returns everything back
I think no. It is much easier to prohibit such a menu altogether (it can be different for everyone / in different browsers) and draw your own - there are plenty of examples.
Yes, all his commands are duplicated in the top menu. I have seen many sites with menus disabled, but copying and reviewing the code was no problem.
You can also just hang onclick on the body which will catch the right-click and return something like return false;
The user for the most part (not considering > 40) knows what a hot-key is. Accordingly, removing the menu will not solve anything. Yes, and onclick on the right button, too. Or really do as Dmitry suggested . Or to carry out serious work on tracking all possible user actions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question