[whatwg] Feature request: Provide event to detect url hash (named anchor) change

Agustín Fernández yo at agustinfernandez.com.ar
Sat Jun 23 14:22:53 PDT 2007


There is currently no way to detect a change in the url of a page other
than polling for changes in document.location.hash all the time (which
is slow and potentially complex, and doesn't always work in IE -) or
listening for click events on all links (which doesn't catch changes not
started by clicking on links -such as clicking back and forward, or
changing the hash by hand-).

Changing the hash in a page is useful to provide bookmarks and back and
forward functionality in ajax driven web applications which never fetch
a new page and is used extensively in the web.

I propose an urlchange (urlhashchange? hashchange? locationchange?)
event which would be dispatched by the BODY element whenever the hash
portion of the url changes.

You can see an example app which uses this in
http://mini.adondevamos.com/ (in spanish).

I filed this in bugzilla:


. A .

More information about the whatwg mailing list