JS to get parameters of static page

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>JS gets the parameters of the static page</title>
</head>
<body>
<Script language="javascript">
function GetRequest() {
	//来源 http://localhost/demo/demo.html?aaa=onestopweb&bbb=demo&ccc=chaoyi
	//location.search to get the question mark and the following parameters?aaa=onestopweb&bbb=demo&ccc=chaoyi
	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]);
		}
	}
	return theRequest;
}
var ClientRequest = GetRequest();
console.info (ClientRequest);
var ReauesKey = ClientRequest ['aaa'];
document.write(ReauesKey);
</Script>
</body>
</html>

 

Effect picture:

 

 

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327043491&siteId=291194637