1function getQueryStringValue (key) {
2 return decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
3}
4
5// Would write the value of the QueryString-variable called name to the console
6console.log(getQueryStringValue("name"));
7