Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to expand navigation options of the context menu on certain elements (specifically, h1 and h2 tags) I want to prevent the browser's default action when right-clicking on those elements.

I found nice information at this page.

However, I couldn't find how to disable the context menu for certain elements. Does someone know how to do it?

I'm using prototype as my javascript API.

like image 984
Lucia Avatar asked Jul 11 '26 13:07

Lucia


1 Answers

This will prevent the context menu from appearing on a particular element

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

So, for example stop all H1/H2 tags from showing a context menu

$$('h1, h2').each(function(it){
    $(it).observe("contextmenu", function(e){
        e.stop();
    });
})
like image 79
James Hughes Avatar answered Jul 14 '26 03:07

James Hughes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!