标签:
var parseQueryString = function (url) { var reg_url = /^[^\?]+\?([\w\W]+)$/, reg_para = /([^&=]+)=([\w\W]*?)(&|$)/g, //g is very important arr_url = reg_url.exec(url), ret = {}; if (arr_url && arr_url[1]) { var str_para = arr_url[1], result; while ((result = reg_para.exec(str_para)) != null) { ret[result[1]] = result[2]; } } return ret; }
//使用方法: var url = "key0=0&key1=1&key2=&key3=http://www.g.cn?a=1&&b=2"; var obj = parseQueryString(url); console.dir(obj);
技术交流QQ群:15129679
标签:
原文地址:http://www.cnblogs.com/yeminglong/p/5881476.html