0

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?

asked Mar 5, 2012 at 14:18
1
  • 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). Commented Mar 5, 2012 at 14:20

2 Answers 2

1

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.

answered Mar 5, 2012 at 14:20
Sign up to request clarification or add additional context in comments.

2 Comments

That's a useful thing to know - do you know if hashchange is fired after every hash-changing keystroke, or only once (after the address bar loses focus/hash location is navigated to)?
@Widor Only when the URL is really changed.
0

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

answered Mar 5, 2012 at 14:21

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.