firefox, how to get the content of location bar? (more words to pass censorship?)

江枫思渺然 提交于 2019-12-11 12:27:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!