js获取链接中的参数
程序员文章站
2024-02-17 22:24:40
...
js获取链接中的参数
<script>
function GetRequest2(key) {
var url = location.search;
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]);
}
}
var value = theRequest[key];
return value;
}
例如链接为:http://www.xxxx?uid=22&token=1231321542132
var uid = GetRequest2("uid")
var token = GetRequest2("token")
</script>
上一篇: 安装WampServer出现的有关问题
下一篇: JAVA Condition