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

[html] 

  1. <span style=”font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);”>test1.html</span>  

[html]

  1. <span style=”font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);”>  
  2. </span>  

[html] 

  1. <span style=”font-family: Arial, Helvetica, sans-serif;”><!DOCTYPE html></span>  

[html] 

  1. <html>  
  2.     <head>  
  3.         <meta charset=”utf-8″>  
  4.         <title>test1.html页面</title>  
  5.         <script type=”text/javascript” src=”../js/jquery-1.11.1.js”></script>  
  6.     </head>  
  7.     <body>  
  8.         请输入:  
  9.         <input type=”text” id=”txta” >  
  10.         <br />  
  11.         第一种方式,传输入的值  
  12.         <input type=button value=”去往test2.html页面” οnclick=”tiaozhuan()” />   
  13.         <script type=”text/javascript”>  
  14.             var tiaozhuan = function(){  
  15.                 document.location.href =’test2.html?mydata1=’ + $(“#txta”).val();  
  16.             }  
  17.         </script>  
  18.         <br />  
  19.         第二种方式,传固定的值  
  20.         <input type=button value=”去往test2.html页面” οnclick=”document.location.href =’test2.html?mydata1=ciweigudingzhi’;” />   
  21.     </body>  
  22. </html>  

 

test2.html

 

[html] 

  1. <!DOCTYPE html>  
  2. <html>  
  3.     <head>  
  4.         <meta charset=”utf-8″>  
  5.         <title>test2.html页面</title>  
  6.     </head>  
  7.     <body>  
  8.         test1.html页面传来的值为:<input type=text id=”txt1″ />  
  9.         <script type=”text/javascript”>  
  10.             var txt1 = document.getElementById(“txt1”);  
  11.             txt1.value = location.search.match(new RegExp(“[\?\&]mydata1=([^\&]+)”, “i”))[1];  
  12.         </script>  
  13.     </body>  
  14. </html>  
    原文作者:@.YX
    原文地址: https://blog.csdn.net/woniu0929/article/details/84349512
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞