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的测试结果来看,截获参数的目的达到了

  • 相关阅读:
    PHP线程安全和非线程安全有什么区别
    SHOW SLAVE STATUS 详解
    linux 2>&1
    crontab 例行性排程
    clang-format 数组初始化,多行模式
    windows 10 1909 无法启用 .NET Framework 解决
    SysCtlDelay 实现延时
    wpa_supplicant 检测错误密码
    swig python dynamic module does not define init function
    讯飞错误码10116
  • 原文地址:https://www.cnblogs.com/xffy1028/p/2344331.html
Copyright © 2011-2022 走看看