1 <script type="text/javascript">
2 function GetRequest(urlStr) {
3 if (typeof urlStr == "undefined") {
4 var url = decodeURI(location.search); //获取url中"?"符后的字符串
5 } else {
6 var url = "?" + urlStr.split("?")[1];
7 }
8 var theRequest = new Object();
9 if (url.indexOf("?") != -1) {
10 var str = url.substr(1);
11 strs = str.split("&");
12 for (var i = 0; i < strs.length; i++) {
13 theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
14 }
15 }
16 return theRequest;
17 }
18 $(function() {
19 alert("asfas");
20 var parms_2 = GetRequest('http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明');
21 alert(parms_2); // {"uid":"admin","rid":"1","fid":"2","name":"小明"}
22 alert(parms_2['name']); // '小明'
23 alert(parms_2['uid']);
24 //alert(GetRequest(urlStr));
25 });
26
27 </script>