您的位置:首页 > Web前端 > JavaScript

js跳转页面并且进行传递参数

2016-10-30 11:46 633 查看
1:方法一:用地址栏传递参数

第一个页面:

<html>
<head>
<title> New Document </title>
<script>
function  to (){
var  getval =document.getElementById("cc").value;
document.location.href("b.html?cc="+getval);
}
</script>
</head>
<body>
<input type="text" id ="cc" > <input type="button"  value="a"  onclick="to()" >
</body>
</html>


第二个页面:

<html>
<head>
<title> New Document </title>
<script>
var thisURL = document.URL;
var  getval =thisURL.split('?')[1];
var showval= getval.split("=")[1];
function  showvalf(){
alert(showval);
document.getElementById('ee').value=showval;
}
</script>
</head>
<body onload="showvalf()">
<input type="text"  id ="ee" />
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: