/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Will convert a url query string key=val&key=val format into an object * * @param string str Url query string * @return object */ my.explode_to_object = function(str) { var cArr = str.split('&'); var cObj = {}; var cLen = cArr.length; for(var cnt=0;cLen--;cnt++) { var cStr = new String(cArr[cnt]); var cElem = cStr.split('='); cObj[cElem[0]] = cElem[1]; } return cObj; }