zoukankan      html  css  js  c++  java
  • 纯HTML页面之间传递参数

    1. <html>  
    2. <head>  
    3.     <meta http-equiv="Content-Type" content="html/text; charset=utf-8"/>  
    4.     <title>JS get Parameter</title>  
    5.     <script src="resource/js/param.js" type="text/javascript"></script>  
    6. </head>  
    7. <body>  
    8. <table>  
    9.     <tr>  
    10.         <td><input type="text" name="user" /></td>  
    11.         <td><input type="text" name="password" /></td>  
    12.         <td><input type="text" name="sysno" /></td>  
    13.     </tr>  
    14. </table>  
    15. </body>  
    16. <script type="text/javascript">  
    17.     var LocString=String(window.document.location.href);   
    18.        
    19.     function getQueryStr(str){   
    20.         var rs = new RegExp("(^|)"+str+"=([^/&]*)(/&|$)","gi").exec(LocString), tmp;   
    21.        
    22.         if(tmp=rs){   
    23.             return tmp[2];   
    24.         }   
    25.        
    26.         // parameter cannot be found   
    27.         return "";   
    28.     }   
    29.   
    30.     document.getElementById("user").value = getQueryStr("user");   
    31.     document.getElementById("password").value = getQueryStr("password");   
    32.     document.getElementById("sysno").value = getQueryStr("sysno");   
    33. </script>  
    34. </html>  

     通过test.html?user=abc&password=123&sysno=001的测试结果来看,截获参数的目的达到了

  • 相关阅读:
    MongoDB学习:(一)MongoDB安装
    事件轮询 Event Loop
    常见的HTML5语义化标签
    前端动画性能优化方案
    前端动画的实现
    《SVN的操作流程及规范》
    css、js文件后的后缀作用是什么?
    实现单行文字溢出显示...,以及多行文字溢出显示...
    从输入URL到页面返回的过程详解
    jQuery实现点击复制效果
  • 原文地址:https://www.cnblogs.com/xffy1028/p/2344331.html
Copyright © 2011-2022 走看看