1.首先我们要创建两个html文件
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action="sss.html">//这里是第二网页的地址,同时记住要在同一个文件夹中
用户名:<input type="text"name="uusernmae">
账号:<input type="number"name="password">
<input type="submit"value="登录">
</form>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="one"></div>
<div class="two"></div>
<script>
//console.log(location.search);//?uusernmae=niu&password=11
var num=location.search.substr(1);?uusernmae=niu&password=11// 这里是截取?以后的值,并把值赋给num。
console.log(num);
var arr1=num.split('&');//把uusernmae=niu&password=11变成数组
console.log(arr1);//['uusernmae=niu', 'password=11']
var arr=arr1[0].split('=');在把arr1[0]也就是uusernmae=niu拆分成数组
console.log(arr);['uusernmae', 'niu']
var arr2=arr1[1].split('=');在把arr1[1]也就是password=11拆分成数组
console.log(arr2);['password', '11']
var div=document.querySelector('.one');
div.innerHTML='姓名'+':'+arr[1];
var news=document.querySelector('.two');
news.innerHTML='年龄'+':'+arr2[1];
</script>
</body>
</html>