var url = location.search.substr(1);
    param = {};
console.log(url);
url.replace(/([^?&]+)=([^?&]+)/g, function(s, v, k) {
    param[v] = decodeURIComponent(k);
    return k + '=' +  v;
});
console.log(param);

例如url为

https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=js%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F&oq=js%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%20kongge&rsv_pq=e63baa94000c303c&rsv_t=2200EoMMe0fGnSJlPpijBDY2Ww1CAkUxvT8jCE2Bif1gXLJ%2Btzixfz%2BAtLE&rsv_enter=1&inputT=294&rsv_sug3=56&rsv_sug1=15&rsv_sug7=100&rsv_sug2=0&rsv_sug4=772&rsv_sug=2

转化结果:

图片描述


炑木
1.4k 声望9 粉丝