How to disable default context menu for certain elements in mozilla using Prototype?

I am trying to expand the navigation options in the context menu for certain elements (in particular, h1and tags h2). I want to prevent the default browser action when I right-click on these elements.

I found some nice information on this page .

However, I could not find how to disable the context menu for certain items. Does anyone know how to do this?

I am using a prototype as my javascript API.

+3
source share
2 answers

This will prevent the context menu from appearing on a specific item.

$(it).observe("contextmenu", function(e){
    e.stop();
});

, , H1/H2

$$('h1, h2').each(function(it){
    $(it).observe("contextmenu", function(e){
        e.stop();
    });
})
+4

, ( , , "" , ). , . , , , . . , , , , . , , , - .

-1

Source: https://habr.com/ru/post/1699359/


All Articles