<script type="text/javascript" language="JavaScript">
//Function
function getQueryString(key) {
var searchString = document.location.search.toString();
var returnValue = '';
if (searchString.substr(0, 1) == '?' && searchString.length > 1) {
var queryString = searchString.substring(1, searchString.length)
var queryList = queryString.split('&');
for (var i = 0; i < queryList.length; i++) {
var oneQuery = queryList[i].split('=');
if (oneQuery[0] == key && oneQuery.length == 2) {
returnValue = oneQuery[1];
}
}
}
return returnValue;
}
//使用方法:
//例如:地址栏为http://www.baidu.com/a.html?a=123&b=456
function getValue()
{
var aValue=getQueryString(a);
var bValue=getQueryString(b);
alert(aValue);//123
alert(bValue);//456
}
</script>