问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/27224902/firefox-how-to-get-the-content-of-location-bar-more-words-to-pass-censorship