<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
URL添加参数“tt”
获取值(例: .html?tt=ddd)
<input type="button" value="test" id="btn_test" οnclick="tt()" />
<script>
function tt() {
alert(getQueryString("tt"));
}
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;
}
</script>
</body>
</html>
js获取URL参数
最新推荐文章于 2024-09-11 21:58:02 发布