0

I am trying to get a hook into the history object. Lets say http://my-site.com is the root url. If someone enters http://my-site.com/<url-fragment> is it possible to listen to the change of the fragment and fire and event associated with that in Javascript?

MIdhun Krishna
  • 1,601
  • 11
  • 28

1 Answers1

0

No.

You can use a beforeunload event to recognise that the page is being left, but you can't find out where it is going to.

You have to wait for the browser to load the new page and then deliver it from the server (well, you could load the homepage then use JavaScript to read location.href, but that would defeat the point of using the history API).

Quentin
  • 800,325
  • 104
  • 1,079
  • 1,205