3

Possible Duplicate:
Detect focus on browser address bar?

Simple question. My guess is that it isn't possible, but still doesn't hurt to ask:

Does anyone know if it is possible to detect the following events:

  • click in the URL bar

  • URL bar text is selected

  • URL bar text keypress

  • URL bar text copy to clipboard

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
fmsf
  • 36,317
  • 49
  • 147
  • 195
  • Why would a website ever want to do this? – ThiefMaster Dec 29 '11 at 09:03
  • To detect if there is a chance a user has copied the hash, so we can store it and when he tries to open the site with that hash we can fully restore the state. Without having to store every single hash. (Every action that triggers js in the site generates a new hash that is then used to restore the view exactly as it is. storing all hashes in the server is just 2 much data) – fmsf Dec 29 '11 at 09:05
  • Why store it? Simply put a json+base64-encoded object containing the necessary data in the hash – ThiefMaster Dec 29 '11 at 10:11
  • 2 much data to fit in the url – fmsf Dec 29 '11 at 21:31
  • Maybe you can limit it to important data and move less important data such as window positions (if your webapp has windows) in a cookie. – ThiefMaster Dec 30 '11 at 01:01

2 Answers2

1

None of these are possible. You can't detect events on the browser window as event handling is limited to the document.

Purag
  • 16,941
  • 4
  • 54
  • 75
0

You can somehow intercept this kind of events in Firefox, using XUL, but only in the context of an extension (maybe it's possible to do the same in Chrome too).

see: Responding to address bar key events in Firefox Add-on

There's no way to intercept these events from the loaded page.

Community
  • 1
  • 1
mamoo
  • 8,156
  • 2
  • 28
  • 38