1

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?

erikvold
  • 15,988
  • 11
  • 54
  • 98
thinker3
  • 12,771
  • 5
  • 30
  • 36
  • I'm going to sleep so ill cheap out on a solution: This is non-sdk way -> Yes see this addon here: https://github.com/Noitidart/ntHotkey https://addons.mozilla.org/en-US/firefox/addon/nthotkey/?src=search – Noitidart Dec 01 '14 at 09:35

1 Answers1

4

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.

erikvold
  • 15,988
  • 11
  • 54
  • 98