Skip to content

Instantly share code, notes, and snippets.

@yantze
Created April 26, 2015 04:54
Show Gist options
  • Save yantze/40791f5ba1512051d7e9 to your computer and use it in GitHub Desktop.
Save yantze/40791f5ba1512051d7e9 to your computer and use it in GitHub Desktop.
get URL parameter
// get URL parameter
function get_param(name)
{
if (location.href.indexOf("?") >= 0) {
var query=location.href.split("?")[1];
var params=query.split("&");
for (var i = 0; i < params.length; i ++) {
value_pair=params[i].split("=");
if (value_pair[0] == name)
return unescape(value_pair[1]);
}
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment