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

To access the URL bar and it's relate value you have to dig into the browser chrome a bit.

This code snippet will get/set the URL bar value for the currently focused browser window:

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 に答える