I want get what I put in the address bar, such as "hello world", not:
var url = tabs.activeTab.url // I don't want this
before I press enter in the address bar. Is it possible to do it in an addon?
I want get what I put in the address bar, such as "hello world", not:
var url = tabs.activeTab.url // I don't want this
before I press enter in the address bar. Is it possible to do it in an addon?
If you define this function in your add-on:
function getURLBarText() {
var { getMostRecentWindow } = require("sdk/window/utils");
var urlBar = getMostRecentWindow().document.getElementById('urlbar');
return urlBar.value;
}
Then calling getURLBarText()
will return whatever is in your active window's url bar.