2

I'd like to modify the context menu for a right click on a specific item (a tr) to display some custom navigation options instead of the standard content. So far, I've found two ways of doing this: either bind some new behavior to the contextmenu event, and create a new div/dropdown menu based on the location of the event, (i.e. create my own context menu from scratch), or else use a plugin like this jQuery plugin that will do the exact same thing for me.

What I'm wondering is if there is a way to use the skeleton of the default context menu, and just add some <a>s or divs that are bound to the events I want to trigger in place of what's already there. Is there a way of modifying the existing context menu, rather than dumping it and building my own either from scratch or with a plugin?

2 Answers 2

5

Is there a way of modifying the existing context menu, rather than dumping it and building my own either from scratch or with a plugin?

No, sorry, the browsers don't expose that functionality.

Sign up to request clarification or add additional context in comments.

1 Comment

Damn. Not the answer I was hoping for.
0

It is possible to modify an existing context menu - the question is only where and when. This is part of HTML5 specification and current version of Firefox supports it.

<menu type="context" id="myVeryOwnMenu">
    <menuitem 
        label="Caption for your item" 
        onclick="veryObtrusiveEventHandler()" 
        icon="/path/to/your/icon.gif">
    </menuitem>
</menu>

...and even nesting is supported.

It seems that Chrome, IE and other leading browsers decide to be not interested about this HTML5 feature. Time will tell.

See http://davidwalsh.name/html5-context-menu for FF demo.

1 Comment

This has since been removed from HTML5, and is only still supported in Firefox. It is considered obsolete and it is inadvisable to use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.