如何通过Firefox扩展程序定位搜索栏?

| 我是构建扩展程序的新手,并且希望获得一些帮助,帮助他们了解如何定位Firefox随附的标准Google搜索栏。 我想我必须找出它是哪个Meni ID并以某种方式在.xul文件中分配它。     
已邀请:
从chrome(通常是chrome://browser/content/browser.xul的覆盖层)中,您可以通过使用document.getElementById(\'searchbar \')来获取搜索栏。查找所需ID的最佳方法是使用Dom Inspector:https://addons.mozilla.org/en-US/firefox/addon/dom-inspector-6622/ 无论如何,如果要访问搜索栏的内部dom元素,则需要使用getAnonymousElementByAttribute,因为这是匿名内容(来自XBL绑定)。因此,如果您需要获取输入元素本身(在其中键入搜索词的位置),则可以通过chrome执行以下操作:
var searchbarElement = document.getElementById(\'searchbar\');
var input = document.getAnonymousElementByAttribute(searchbarElement, \'anonid\', \'input\');
您将需要使用Dom Inspector来确定所需的元素以及如何访问它。     

要回复问题请先登录注册