标签:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="/script/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
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;
}
function getUrl(urlName)
{
var Request = new Object();
Request = GetRequest();
return Request[urlName];
}
</script>
</head>
<body>
<input type="button" value="方法一获取URL参数" id="method1" onclick="alert(getQueryString(‘id‘));" />
<input type="button" value="方法二获取URL参数" id="method2" onclick="alert(getUrl(‘id‘))" />
</body>
</html>
标签:
原文地址:http://www.cnblogs.com/haitunsw/p/4309099.html