FF extension: a popup with dynamic menuitems, with each menu item having another popup

帅比萌擦擦* 提交于 2019-12-12 10:24:34

问题


I am building an extension that has a popup whose elements are constructed by a function call everytime the mouse hovers over the popup option. I am able to achieve this. Now I need to have a popup for each of the menu item (inside the original popup) which is not dynamic though. I have this code, but it does not work:

var myMenuPopup = document.getElementById("file-popup4");

for (var m=0; m<localpubliclist.length; m++)
{

    var newItem = document.createElement("menupopup");

    newItem.setAttribute("label", publicdisplayname[m]);

    newItem.setAttribute("id", "public" + m);

    var new1 = document.createElement("menuitem");
    new1.setAttribute("label","Home");
    new1.setAttribute("id", "publichome" + m);
    newItem.onclick = function(){
    };
    newItem.appendChild(new1);
    myMenuPopup.appendChild(newItem);

but this doesnt work. That is, the popup(newitem) does not open. Can someone please help me out with whats the problem


回答1:


Have you tried the onpopupshowing event (https://developer.mozilla.org/en/XUL/menupopup#a-onpopupshowing)?



来源:https://stackoverflow.com/questions/2780696/ff-extension-a-popup-with-dynamic-menuitems-with-each-menu-item-having-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!