admin 管理员组文章数量: 1087134
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 know you can get the document URL via window.location.href
, but I am unable to locate any javascript pertaining to current code inside the address bar/omnibar.
Thank you for the help!
EDIT: This is for an extension.
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 know you can get the document URL via window.location.href
, but I am unable to locate any javascript pertaining to current code inside the address bar/omnibar.
Thank you for the help!
EDIT: This is for an extension.
Share Improve this question edited Apr 19, 2010 at 23:33 Cyclone asked Apr 19, 2010 at 23:16 CycloneCyclone 18.3k47 gold badges128 silver badges195 bronze badges 2- 4 That's not something belonging to the site you're running JS in. It makes no sense to grant access to something that's way out of scope. Next thing you want is accessing the user's files? – Joey Commented Apr 19, 2010 at 23:23
- 3 It's not a site, its an extension. – Cyclone Commented Apr 19, 2010 at 23:31
3 Answers
Reset to default 7Even 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 pletely impossible.
I believe this is impossible. It may be doable in a extension.
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 es) 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.
本文标签: javascriptGet text (not url) from address bar in Google ChromeStack Overflow
版权声明:本文标题:javascript - Get text (not url) from address bar in Google Chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744069096a2528158.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论