2

Is there any way I can add an item to the context menu using JavaScript and HTML? I will use Flash if necessary.

This question has been answered here, but the solution was to create your own context menu. I just want to add an item to it, like seen in this Flash game. Is this only possible with Flash?

LuckyLuke Skywalker
  • 610
  • 2
  • 5
  • 17
Ptr13
  • 553
  • 2
  • 6
  • 14

2 Answers2

1

If I correctly understood you need to add items to flashplayer context menu, and it is possible with actionscript:

var cMenu:ContextMenu = new ContextMenu();
var item1:ContextMenuItem = new ContextMenuItem("some text");
cMenu.hideBuiltInItems();
cMenu.customItems.push(item1);
contextMenu=cMenu;

item1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, func1);

function func1(e:ContextMenuEvent):void{
    //do some thing when item1 clicked
}

find more in this tutorial.

null.point3r
  • 1,053
  • 2
  • 9
  • 17
0

The only way to add buttons to a browser default context menu is developing an extension for the browser.

So you need your custom context menu which can be done using HTML elements (+JavaScript), or Flash. Of course Flash Player is installed on most browsers nowadays; but there's a very low possibility that your website viewer doesn't have Flash Player installed on his browser.

Therefore, I suggest you to create your context menu using HTML + CSS + JavaScript (jQuery will help a lot). For examples, you may want to take a look at MediaFire, Yahoo! Mail, etc.

Javid
  • 2,755
  • 2
  • 33
  • 60
  • If you looked at the Flash game I showed, you would see that it just _added_ an item, not creating a new menu. – Ptr13 Sep 07 '13 at 00:51
  • 1
    @Ptr13: This Flash game has added an item to its own menu! Not the browser context menu! – Javid Sep 07 '13 at 14:41
  • 1
    I realize this is an old post, but it's a high up hit in google for this topic, so I'm linking an answer from a similar thread in SO. The question from the link is greasemonkey specific, but the answer contains javascript and jquery code that will answer *this* question using *this* answer's methods. http://stackoverflow.com/questions/6017187/userscript-add-item-to-right-click-menu/24145259#24145259 – Heath Carroll Dec 22 '15 at 18:56