Skip to content

Instantly share code, notes, and snippets.

@danmartens
Created December 6, 2012 19:55
Show Gist options
  • Save danmartens/4227770 to your computer and use it in GitHub Desktop.
Save danmartens/4227770 to your computer and use it in GitHub Desktop.
Parses location.hash into an Object
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