HTML一个页面输入值跳转到另一个页面并且显示出来

1.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="jquery.min.js"></script>
</head>
<body>
请输入:
<input type="text" id="txta" >
<br />
第一种方式,传输入的值
<input type=button value="去往test2.html页面" onclick="tiaozhuan()" />
<script type="text/javascript">
    var tiaozhuan = function(){
        document.location.href ='2.html?mydata1=' + $("#txta").val();
    }
</script>
<!--<br />-->
<!--第二种方式,传固定的值-->
<!--<input type=button value="去往test2.html页面" onclick="document.location.href ='2.html?mydata1=ciweigudingzhi';" />-->
</body>
</html>

2.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
test1.html页面传来的值为:<input type=text id="txt1" />
<script type="text/javascript">
    var txt1 = document.getElementById("txt1");
    txt1.value = location.search.match(new RegExp("[\?\&]mydata1=([^\&]+)", "i"))[1];
</script>
</body>
</html>

 

 

来源:http://blog.csdn.net/z88xiaodong/article/details/48323199

 

http://blog.csdn.net/lingling_jy/article/details/8191107

 

posted @ 2016-08-15 17:19  chenxj  阅读(621)  评论(0)    收藏  举报