JS获得URL参数

使用JavaScript获得URL在参数值
方法一:
function getUrlParam(name) { 
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标參数的正則表達式对象 
    var r = window.location.search.substr(1).match(reg); //匹配目标參数 
    if (r != null) return unescape(r[2]); return null; //返回參数值 
}
方法二:

function GetRequest() {

   var url = location.search;//获取url中"?"符后的字串

   var theRequest = new Object();

   if (url.indexOf("?") != -1) {

      var str = url.substr(1);

      strs = str.split("&");

      for(var i = 0; i < strs.length; i ++) {

         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);

      }

   }

   return theRequest;

}


var Request = new Object();
Request = GetRequest();

var 參数1,參数2,參数3,參数N;

參数1 = Request['參数1'];

參数2 = Request['參数2'];

參数3 = Request['參数3'];

参数N = Request['参数N'];