Get text (not url) from address bar in Google Chrome

后端 未结 3 1839
既然无缘
既然无缘 2021-01-13 12:28

I want to retrieve the text that the user has typed into the currently visible address bar, using Javascript. This is for google chrome only.

Is this possible? I kno

相关标签:
3条回答
  • 2021-01-13 12:37

    It seems this will be supported by chrome extensions in the future.

    For the time being, depending on your needs, the closest you could ever get would be to fake a second address bar just below the real one, styling it so it looks like a double address bar.

    This would be implemented via a DOM bar, akin to StumbleUpon's, kinda like Chrome's own infobars. But being your content-script's JS, you would have full control over it, and as I said, depending on your needs it could be a sub-optimal solution for your users.

    The only advantage I can see over native support (when it comes) is that, if you want to use the address bar for things other than the url, then you'd do it in the fake bar and still keep the page's url accessible to the user at all times in the native bar.

    0 讨论(0)
  • 2021-01-13 12:46

    Even with extensions this is impossible -- at least in google chrome.

    Under the current extensions platform for Chromium, addons are little more than javascript programs with minorly elevated privileges; the nearest correspondence would be the Greasemonkey scripts so popular in Firefox.

    As an extension developer, I am very unhappy with this situation, and am looking forward to its (inevitable) change and growth.

    For the moment, unfortunately, such things as your question are completely impossible.

    0 讨论(0)
  • 2021-01-13 12:48

    I believe this is impossible. It may be doable in a extension.

    0 讨论(0)
提交回复
热议问题