Created
December 6, 2012 19:55
-
-
Save danmartens/4227770 to your computer and use it in GitHub Desktop.
Parses location.hash into an Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.parseHash = function() { | |
var parsed = {}; | |
var pairs = window.location.hash.replace('#', '').split('&'); | |
pairs.forEach(function(pair) { | |
parsed[pair.split('=')[0]] = (parseInt(pair.split('=')[1], 10) || pair.split('=')[1]); | |
}); | |
return parsed; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment