W
W
weranda2016-05-22 11:43:43
JavaScript
weranda, 2016-05-22 11:43:43

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

5 answer(s)
I
Ivan Bogachev, 2016-05-22
@sfi0zy

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

D
Dmitry, 2016-05-22
@thewind

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.

A
Alexander, 2016-05-22
@NeiroNx

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.

V
Vladimir Grabko, 2016-05-22
@VGrabko

You can also just hang onclick on the body which will catch the right-click and return something like return false;

D
Denis Golub, 2016-05-23
@den_golub

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 question

Ask a Question

731 491 924 answers to any question