一个js获取url参数的例子,贴一贴
<script type="text/javascript">
//获取Url地址参数,调用方式如下
//var req = RequetParame(window.location);
//alert(req.id);
//alert(req.aa);
function RequetParame(_url) {
var url = _url.search.replace("?", "").replace(/=/ig, ":");
var s = url.split("&");
var info = "{";
for (var i = 0; i < s.length; i++) {
info += '"' + s[i].split(":")[0] + '"' + ":" + '"' + s[i].split(":")[1] + '"' + ",";
}
info = info.substring(0, info.length - 1);
info += "}";
var info = eval("(" + info + ")");
return info;
}
var req = RequetParame(window.location);
alert(req.id);
alert(req.aa);
</script>