[Javascript] capturing changes to the fragment identifier

Paul Novitski paul at juniperwebcraft.com
Fri May 30 12:29:48 CDT 2008


At 5/30/2008 10:04 AM, John Zabroski wrote:
>For those who don't know, the fragment identifier is everything 
>after the pound symbol (#) aka the hash symbol.  It is intended to 
>be used as a way to navigate within a document and bookmark that 
>section of a document.  Gmail uses it to determine what to load into 
>iframes, using iframes as a model for recording 'hard state' and 
>'soft state' for the application.  My use case is similar to Gmail.
...
>Currently, there does not appear to be a cross-browser compatible 
>method for handling changes to the fragment identifier as an 
>event.  IE8 is planning to support onHashChange as an event handler, 
>but it does not appear to be a w3c standard.
>
>Such an event handler would be ideal, since it would push all 
>updates to hard and soft state into a single point: a resource.
>
>How can I do this cross-browser?  FF1.5+, IE7+, and Safari is pretty 
>much the bare minimum support required version-wise, but I'd prefer 
>to support it feature-wise and deterministically figure out what 
>browsers can even do this.


One approach might be to apply onclick and onkeypress events to all 
anchors with hrefs containing fragment identifiers, and then process 
the changes to the hash with one central function when any of the 
links is activated.

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com 




More information about the Javascript mailing list