Skip to content

Instantly share code, notes, and snippets.

@alvaropinot
Last active August 29, 2015 14:15
Show Gist options
  • Save alvaropinot/43a13c1ca697aaedfd85 to your computer and use it in GitHub Desktop.
Save alvaropinot/43a13c1ca697aaedfd85 to your computer and use it in GitHub Desktop.
simple url arguments reader
//remove the starting '?' and split options
location.search.slice(1).split("&").forEach(function(opt) {
opt = opt.split('=');
console.log(opt); // ['arg1','val1'] ['arg2','val2']
});
var query = window.location.search.substring(1);
if (!query) {
var hash = window.location.hash;
query = hash.slice(hash.indexOf('?') + 1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment