0

I am trying to add to the context menu programmatically in Javascript. The model I'm using is vsync's answer here: https://stackoverflow.com/a/9293946/322537

And I am changing it into Javascript. What I have you can see in this fiddle:
http://jsfiddle.net/pB76y/

..

As you can see, if you right click the upper image you can see the new context menu 'View Plate Thumbnail'. But if you change the id of the menu from 'menu_from_image' to 'menu_from_image_js' (which is the javascript version), then you should get the lower image behaving the same way. But it doesn't.
Why?

1 Answer 1

1

You had everything right but it seems that you weren't setting the attribute on the DIV in a way that the browsers was recognizing. Instead of using

cmenu.contextmenu = 'menu_for_image_js';

I altered it to be:

cmenu.setAttribute('contextmenu','menu_for_image_js');

I've created a JS Fiddle that shows the change based on your example: http://jsfiddle.net/pB76y/1/

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

Comments

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.