<head></head> <body> </body> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <Script language="javascript"> $(window).load(function(){ var url = "http://item.taobao.com/item.html?a=1&b=2&c=&d=xxxx&e"; var obj = GetRequest(url); console.log(obj); }); function GetRequest(url) { var theRequest = new Object(); if (url.indexOf("?") != -1) { //获取url中"?"符后的字串 var index = url.lastIndexOf("?"); var str = url.substring(index+1, url.length); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]); } } return theRequest; } </Script>
标签:theRequest,url,GetRequest,js,strs,参数,split,var From: https://www.cnblogs.com/QW-lzm/p/17008086.html