Skip to content

Instantly share code, notes, and snippets.

@jtribble
Last active September 23, 2015 02:20
Show Gist options
  • Save jtribble/9c3122cff17f7b6fcdcc to your computer and use it in GitHub Desktop.
Save jtribble/9c3122cff17f7b6fcdcc to your computer and use it in GitHub Desktop.
/**
* Get Hash Parameter
*
* Ex. /page/#/param/value
*
* @param {string} name
* @return {string}
*/
var getHashParameter = function (param) {
var paramStr = '/#/' + param + '/',
paramStrIndex = location.href.indexOf(paramStr);
if (paramStrIndex !== -1) {
var pathResult = location.href.substring(paramStrIndex + paramStr.length);
return pathResult.split('/')[0];
}
return '';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment