两个html页面互相传值

来源:互联网 发布:张东健在韩国地位 知乎 编辑:程序博客网 时间:2024/05/17 23:46

从a.html 跳转到b.html 并吧 a.html 的值传入b.html


a.html

[html] view plaincopy
  1. <html>  
  2.  <head>  
  3.   <title> New Document </title>  
  4.     <script>  
  5.       function   to (){  
  6.         var  getval =document.getElementById("cc").value;  
  7.         document.location.href("b.html?cc="+getval);     
  8.       }  
  9.     </script>  
  10.  </head>  
  11.  <body>  
  12.   <input type="text" id ="cc" > <input type="button"  value="a"  onclick="to()" >  
  13.  </body>  
  14. </html>  

b.html

[html] view plaincopy
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">  
  2. <html>  
  3.  <head>  
  4.  <title> New Document </title>  
  5.  <script>    
  6.   var thisURL = document.URL;    
  7.   var  getval =thisURL.split('?')[1];  
  8.   var showvalgetval.split("=")[1];  
  9.   function  showvalf(){  
  10.      alert(showval);  
  11.      document.getElementById('ee').value=showval;  
  12.   }  
  13. </script>  
  14.  </head>  
  15.  <body onload="showvalf()">  
  16.   <input type="text"  id ="ee" />  
  17.  </body>  
  18. </html> 
0 0
原创粉丝点击