第一种方法:
var $_GET = new Object();
var _Rep = document.location.search.replace(/(\?|&)([\w\d_]+)=([^&]+)/g, "_GET['$2']='$3';$");
eval('$' + unescape(_Rep.substr(0, _Rep.length - 1)));
for (i in $_GET) document.write(i + '=>' + $_GET[i] + '<br>');
var _Rep = document.location.search.replace(/(\?|&)([\w\d_]+)=([^&]+)/g, "_GET['$2']='$3';$");
eval('$' + unescape(_Rep.substr(0, _Rep.length - 1)));
for (i in $_GET) document.write(i + '=>' + $_GET[i] + '<br>');
第二种方法:
function Request(strName)
{
var strHref = window.document.location.href;
var intPos = strHref.indexOf("?");
var strRight = strHref.substr(intPos + 1);
var arrTmp = strRight.split("&");
for(var i = 0; i < arrTmp.length; i++)
{
var arrTemp = arrTmp[i].split("=");
if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
}
return "";
}
alert(Request("id"))
{
var strHref = window.document.location.href;
var intPos = strHref.indexOf("?");
var strRight = strHref.substr(intPos + 1);
var arrTmp = strRight.split("&");
for(var i = 0; i < arrTmp.length; i++)
{
var arrTemp = arrTmp[i].split("=");
if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
}
return "";
}
alert(Request("id"))