Skip to content

Instantly share code, notes, and snippets.

@lzl124631x
Created May 25, 2016 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lzl124631x/39068129b7468bc915e87409bcfb2c92 to your computer and use it in GitHub Desktop.
Save lzl124631x/39068129b7468bc915e87409bcfb2c92 to your computer and use it in GitHub Desktop.
get parameter in query string by name
function getParameterByName (name) {
var undefined;
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? undefined : decodeURIComponent(results[1].replace(/\+/g, " "));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment