Skip to content

Instantly share code, notes, and snippets.

@dieseltravis
Created January 12, 2009 16:22
Show Gist options
  • Select an option

  • Save dieseltravis/46038 to your computer and use it in GitHub Desktop.

Select an option

Save dieseltravis/46038 to your computer and use it in GitHub Desktop.
javascript querystring function
function querystring(param) {
if (location.search.length > 1) {
var qsArgs = location.search.substring(1, location.search.length).replace(/\+/g, " ").split("&");
for (var i = 0; i < qsArgs.length; i++) {
var pair = qsArgs[i].split("=");
var key = decodeURIComponent(pair[0]);
if (param == key) {
var value = (pair.length === 2)? decodeURIComponent(pair[1]): key;
return value;
}
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment