Skip to content

Instantly share code, notes, and snippets.

@zoxon
Forked from d-simon/query_string_parameter.js
Created December 22, 2016 03:05
Show Gist options
  • Save zoxon/69ad77d3827c39ee3d66901ac49a6ed6 to your computer and use it in GitHub Desktop.
Save zoxon/69ad77d3827c39ee3d66901ac49a6ed6 to your computer and use it in GitHub Desktop.
Query String Parameters
// http://stackoverflow.com/a/901144
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment