//获取参数 修复中文参数的获取
1 function GetRequest() {
2 var url = location.search; //获取url中"?"符后的字串
3 var theRequest = new Object();
4 if (url.indexOf("?") != -1) {
5 var str = url.substr(1);
6 strs = str.split("&");
7 for(var i = 0; i < strs.length; i ++) {
8 theRequest[strs[i].split("=")[0]]=decodeURIComponent(strs[i].split("=")[1]);
9 }
10 }
11 return theRequest;
12 }
获取参数
1 //获取参数 不推荐使用,获取的参数如果有中文将出现乱码 2 function GetRequest() { 3 var url = location.search; //获取url中"?"符后的字串 4 var theRequest = new Object(); 5 if (url.indexOf("?") != -1) { 6 var str = url.substr(1); 7 strs = str.split("&"); 8 for(var i = 0; i < strs.length; i ++) { 9 theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); 10 } 11 } 12 return theRequest; 13 }
返回值为undefined null 检测
1 function undefinedData(v){ 2 if(v=='undefined'||v==null){ 3 return ' '; 4 }else{ 5 return v; 6 } 7 }