window.location.search

作用:取得【http://111111?A=1&B=2&C=3....】红色部分

上代码,起个名字:123.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
</head>
<body>		
<script language="javascript">
	alert(window.location.search.substr(1).split("&"));
	alert(window.location.search.split('&').join('|'));
</script>
</body>
</html>

然后访问:。。。。123.html?topic=1&id=2

效果:

原文地址:https://www.cnblogs.com/wang-s/p/4664030.html