getQueryString

Reading QueryString from JS

<script>

function getQueryString() {
var result = {}, queryString = location.search.slice(1),
re = /([^&=]+)=([^&]*)/g, m;
while (m = re.exec(queryString)) {
result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
}
return result;
}
var myParam = getQueryString()["myParam"];
var queryDict = {}
location.search.substr(1).split("&").forEach(function(item) {queryDict[item.split("=")[0]] = item.split("=")[1]})

</script>

Views 110 Downloads 50

Perm link


ANmarAmdeen
283
Sessions JS+JQuery
Revisions

v1.0