Ajax Bestiary: A Javascript Field Guide
 
Ajax Bestiary: A Javascript Field Guide
 
 

Customized context menu handling with jQuery

Posted by Dave Mahon

Can you think of some times you might want to disable the right click context menu? Or better still, insert your own behavior or application specific context menu?

This is a simple and useful trick:

element.bind('contextmenu',function(e){
    //Optional customized handling here
    return false;
});

If you don’t return false, the normal context menu will appear, which could actually be desirable, depending on what exactly you want it to do (say, exiting a field and recording it as dirty).


1 Comment

  • Thanks for chiding us, TambourineMan. We promise to do better. And, Julia, that passage you quoted here is one so many of us can relate to ccna

Leave a Reply