I know it's possible to run JavaScript from the address bar, but are there any DOM events or exposed objects that let you interact with it through script?
I imagine not for security reasons but for example, are there any events such as onfocus that could let you know when a user is using the address bar and not the webpage?
Or perhaps there are methods available elsewhere on the page which one could use to deduce that the user is typing in the address bar. Similarly, I know you can do ugly things like history.go(-1) but can you tell when the 'back' button is clicked?
-
I guess it depends on the browser and what kind of script you're running. Chrome extensions can alter it (to a quite limited extent).pimvdb– pimvdb2012年03月05日 14:20:46 +00:00Commented Mar 5, 2012 at 14:20
2 Answers 2
That is not possible, for very obvious security reasons.
One exception is the hashchange event, which is triggered every time that the location hash changes.
The simple answer is NO ... you cannot interact with the browsers address bar / other controls - its out of reach of JavaScript due to security constraints