Bootstrap

编写一个JavaScript函数 parseQueryString,把URL参数解析为一个对象

var url = "http://www.taobao.com/index.php?key0=0&key1=1&key2=2.............";

function parseQueryString(argu){

    var str = argu.split('?')[1];
    console.log(str);
    var result = {};
    var temp = str.split('&');
    console.log(temp);
    console.log(temp.length);

    for(var i=0; i<temp.length; i++){
        var temp2 = temp[i].split('=');
        console.log(temp2);
        result[temp2[0]] = temp2[1];
    }
    return result;
}
var obj = parseQueryString(url);
console.log(obj);


主要利用split()来分割数组


;