Is there a way to override the "undo" and "select all" in right click context menu of the browser over textarea?
Thank you.
Is there a way to override the "undo" and "select all" in right click context menu of the browser over textarea?
Thank you.
I know you can prevent the whole context menu from opening by registering to the click() event, doing some cross-browser mumbo-jumbo to get wich button was clicked, and then return false if the right one was clicked.
However, I don't think it's possible to modify the context menu itself, at least not using javascript.
I should add that you may want to rethink why you're doing this. This will never be a protection against anything (some try to prevent copying images from their website), as it may simply be disabled by turning javascript off.
UPDATE: Ok, so you don't want to prevent users to do things, bug have them doing things your way. Then, I guess the best thing to do is :
You mentionned in another comment that you cannot reproduce copy/paste, which is correct, but you can implement you own clipboard (that will only work for your webapp) if you really have to.
You cannot edit the browser's built-in context menu, but you can disable it and replace it with your own using the oncontextmenu
event on the window
object. I would caution that this is often a bad idea. Users expect to find the built-in context menu and are often frustrated when it isn't there.