js 获取URL中的参数并转换为对象

 

var $_REQUEST = new Object, aParams = document.location.search.substr(1).split("&");
for (i = 0; i < aParams.length; i++) {
  var aParam = aParams[i].split("=");
  $_REQUEST[aParam[0]] = aParam[1]
}

例: url  http://www.xxx.net/x/x.html?id=898602B8261890349226&aaa=123&ccc=456

aParams   =   ["iccid=898602B8261890349226", "aaa=123", "ccc=456"]

$_REQUEST   = {iccid: "898602B8261890349226", aaa: "123", ccc: "456"}

 

posted @ 2018-11-07 16:41  哦一哦啊啊  阅读(5311)  评论(0编辑  收藏  举报