Skip to content

Instantly share code, notes, and snippets.

@debonx
Last active November 21, 2018 15:31
Show Gist options
  • Save debonx/a5a8c6754f1cc065e97b2bbabc8a1c7b to your computer and use it in GitHub Desktop.
Save debonx/a5a8c6754f1cc065e97b2bbabc8a1c7b to your computer and use it in GitHub Desktop.
JQuery / Javascript small function to get url parameters, for example https://your-link?param=value.
function get_url_param(name){
var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href);
if (results==null){
return null;
} else {
if(results[1].indexOf("#")){
results = results[1].split("#");
results = results[0];
} else {
results = results[1] || 0;
}
return results;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment