This project is archived and is in readonly mode.

#778 ✓invalid
sdf1981cgn

Add hashchange event

Reported by sdf1981cgn | November 5th, 2009 @ 04:53 PM | in 2.0 (closed)

Internet Explorer 8 and Firefox 3.6 have the "onhashchange" event introduced.

How about an implementation for mt:

Element.Events.hashchange = {
    onAdd: function(){
        var hash = self.location.hash;

        var hashchange = function(){
            if (hash == self.location.hash) return;
            else hash = self.location.hash;

            var value = (hash.indexOf('#') == 0 ? hash.substr(1) : hash);
            window.fireEvent('hashchange', value);
            document.fireEvent('hashchange', value);
        };

        if ("onhashchange" in window){
            window.onhashchange = hashchange;
        } else {
            hashchange.periodical(50);
        }
    }
};

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Pages