firefox扩展如何访问边栏元素
如果我的firefox扩展中有侧边栏。如何使用侧边栏javascript访问某些元素(如文本框)以修改其值 在文本框上设置id。使用此选项可以访问它:firefox扩展如何访问边栏元素,firefox,firefox-addon,Firefox,Firefox Addon,如果我的firefox扩展中有侧边栏。如何使用侧边栏javascript访问某些元素(如文本框)以修改其值 在文本框上设置id。使用此选项可以访问它: document.getElementById("theId").value = "new text"; 如果您需要从脚本覆盖browser.xul访问侧栏(或者确实需要从侧栏脚本访问浏览器),请按以下步骤查看这些内容。 我为我编写的一个附加组件做了以下工作: function displayOnSideBar(text) { cons
document.getElementById("theId").value = "new text";
如果您需要从脚本覆盖browser.xul访问侧栏(或者确实需要从侧栏脚本访问浏览器),请按以下步骤查看这些内容。 我为我编写的一个附加组件做了以下工作:
function displayOnSideBar(text) {
const win = document.getElementById("sidebar").contentWindow;
dump("location.href:" + win.location.href);
if (win.location.href == "chrome://scrapbook/content/scrapbook.xul") {
const label = win.document.getElementById("toolbar-label");
label.value = text;
return true;
} else {
dump("displayOnSidebar return false");
return false;
}
},
在scrapbook.xul中,我有如下内容:
<toolbar id="sbMainToolbar">
.....
<!-- this is useful for other add-ons such as simple-timer
to display some information -->
<label id="toolbar-label" value="" flex="1"/>
.....
..您想访问加载页面或XUL中的html“输入”元素吗?我想更新侧边栏中的XUL文本框。