1

I work with a https://addons.mozilla.org/en-US/developers/builder (Add-ons builder) and I try to do the following things:

1.How to change currentURI address? Method setTabURL() is not suitable because immediately opens the URL.

While found a way out:

tab.attach ({
    contentScript: "history.pushState ('','', '" + tab.url + "');",
});

2.How to get the url address that is entered in the address bar? Method getTabURL() only shows the address at which settled.

3.How to add text to an icon in the toolbar? I use it here: https://builder.addons.mozilla.org/package/166563/

4

1 回答 1

6

要访问 URL 栏及其相关值,您必须深入研究浏览器 chrome。

此代码片段将获取/设置当前焦点浏览器窗口的 URL 栏值:

var wuntils = require('sdk/window/utils');
var document = wuntils.getMostRecentBrowserWindow().document;
// log the current URL bar value
console.log(document.getElementById("urlbar").value);
// change the current URL bar value (this won't change the page)
document.getElementById("urlbar").value = "Thrift Shop";
于 2013-02-21T21:42:20.463 回答