1 function getQueryStringArgs() { 2 var arr = location.search?location.search.substring(1):'';//取得参数字符串并去掉开头的问号 3 var obj = {}; 4 if(arr){ 5 var arr2 = arr.split('&'); //取得每一项 6 for(var i in arr2){ 7 var arr3 = arr2[i].split('='); 8 var name = decodeURIComponent(arr3[0]); 9 var value = decodeURIComponent(arr3[1]); 10 obj[name] = value; //逐个将每一项添加到 obj对象中 11 } 12 } 13 return obj; 14 }