Adrian Ex Machina

Husband, father, designer, developer, cyclist, photographer. Exceeding expectations since 1982.
Thu Aug 13

Javascript: Get query string as an object

A little function that takes the query string and turns it into an object thats easily referenced.

	function queryString(){
		var qArr = {};
		var sstring = window.location.search.substring(1).split("&");
		for (i=0;i<sstring.length;i++) {
			var thisVal = sstring[i].split("=");
			qArr[thisVal[0]] = thisVal[1];
		}
		return qArr;
	}