Firefox extension elements id

十年热恋 提交于 2019-12-11 13:46:49

问题


Can someone tell me where can I find the ids of browser elements in Firefox?

I want to put a menupopup in the web developer section in Firefox and I need an id to put into the insertafter attribute.


回答1:


You can see all the IDs in the source code of browser.xul as well as its include files like browser-sets.inc. Alternatively, you can inspect the browser window at runtime using the DOM Inspector extension.




回答2:


The web developer menupopup can be found in:

http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser-appmenu.inc#144

<menupopup id="appmenu_webDeveloper_popup">
  <menuitem id="appmenu_devToolbox">
  ...

Alternatively, If you have DOM Inspector, open it and go to menu:

File->Inspect Chrome Document->chrome://browser/content/browser.xul

(browser.xul should usually be the first item (1) with the same title as the browser's taskbar or current tab).

Then search for ID=appmenu_webDeveloper_popup. Many of the other menus can be found at ID=mainPopupSet.


Also, this scratchpad snippet lists the IDs of child elements contained in the web developer menupopup (set scratchpad environment to browser, execute as display to output the result ):

var webdev=document.getElementById("appmenu_webDeveloper_popup");
var idList=Array.prototype.slice.call(webdev.children).map(function(node){
    return node.id;
}).filter(function(id)id);
idList.join("\n");


来源:https://stackoverflow.com/questions/16736071/firefox-extension-elements-id

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