// alert(location.search.length); //13 处理的数据如下:http://www.js.com/1.html?name=wuleia
// alert(location.search.substring(1)); //name=wuleia
// var qs = location.search.substring(1);
// var cs = qs.split("&");
// alert()
//location.search.length
//http://www.js.com/1.html?name=wuleia&age=30
var url = location.search.length > 0 ? location.search.substring(1) : ""; //name=wuleia&age=30
var liurl = url.length > 0 ? url.split("&") : [];
//var ar = Array.isArray(liurl); //true;
var ob = {}; //字面量对象
//alert(liurl.toString()); //name=wuleia,age=30
//打印出每一个参数
// for(i=0; i<liurl.length; i++ ){
// alert(liurl[i]);
// }
//也可以使用js数组的迭代方法;传入函数对每一个参数进行处理;
var li = null;
var liname = null;
var livalue = null;
//使用for循环把取得的,分隔的参数,存入到对象中去;
var i = 0;
var len = liurl.length;
//alert(liurl[0]);
// name=wuleia,age=30
// var item = liurl.splice("=");
// alert(item);
for(i = 0; i < len; i++){
var item = liurl[i].split("=");
liname = decodeURIComponent(item[0]);
livalue = decodeURIComponent(item[1]);
if(liname.length){
ob[liname] = livalue;
}
return ob;
}