HTML页面之间参数的传值
login.html中:
功能:点击忘记密码按钮时,将input输入框中的值,传递给forget.html
<script type="text/javascript">
function jump(){
var username = document.getElementById("username").value;
url = "forget.html?name="+username;
window.location.href = url;
}
</script>
<p style="text-align:center;">用 户 名:
<input id=username><br></p>
<a href="javascript:jump()"><input type="button" name="button" value="忘记密码"></a></p>
forget.html中:
功能:接收从login.html文件中传递过来的参数,并将这个参数显示在forget.html的input输入框中
<script type="text/javascript">
function getData(){
var name = window.location.search;
var name = name.slice(6, );
document.getElementById("name").value = name;
}
</script>
<p style="text-align:center;">用 户 名:
<input id="name" readonly><br></p>
这里的用户名就是由login界面参数传递过来的值,且已设置为readonly只读属性