javascript Loop through QueryString
function LoopThroughQueryString(obj) { //loops through queryString var queryString = unescape(location.search); //if no querystring (homepage etc.) then exit if (!queryString) { return {}; } //remove the ? queryString = queryString.substring(1); //split querystring into key/value pairs var pairs = queryString.split("&"); //load the pairs into a collection for (var i = 0; i < pairs.length; i++) { //split into key/value pair by splitting on = var keyValuePair = pairs[i].split("="); //keyValuePair[0] = key //keyValuePair[1] = value if (keyValuePair[0] == 'Key') { alert("Value = " + keyValuePair[1]; } } }
Splits a QueryString into an array and loops through it - looking for a match.
Updated: Thursday 7th October 2010, 10:50pm
There are 0 comments
Comments are currently closed.