參數傳遞的四種形式----- URL,超鏈接,js,form表單


什么時候用GET,  查,刪,

什么時候用POST,增,改  (特列:登陸用Post,因為不能讓用戶名和密碼顯示在URL上)

4種get傳參方式

 

[html]  view plain copy
 
  1. <html xmlns="http://www.w3.org/1999/xhtml">  
  2. <head>  
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  
  4.     <title></title>  
  5.     <script type="text/javascript">  
  6.         function Go() {  
  7.             window.location.href="localhost:21811/Handler1.ashx?id=1&name='abc'"  
  8.         }  
  9.     </script>  
  10. </head>  
  11. <body>  
  12.   
  13.    <!--//參數傳遞的幾種形式-->  
  14.     <!--第一種:直接在URL后面加參數:-->  
  15.     localhost:21811/Handler1.ashx?id=1&name="abc"  
  16.   
  17.   
  18.     <!--第二種:用超鏈接的方法傳遞參數:當點擊超鏈接的時候,首先會跳轉到localhost:21811/Handler1.ashx頁面,然后還會傳遞id 和name 兩個參數過去-->  
  19.     <href="localhost:21811/Handler1.ashx?id=1&name='abc'">超鏈接傳遞參數</a></body>  
  20.   
  21.     <!--第三種:通過js方法傳遞:用戶點擊這個button按鈕,觸發onClick事件,執行Go()方法,跳轉到localhost:21811/Handler1.ashx頁面,同時傳遞了id,和name兩個參數過去-->  
  22.     <input type="button" onclick="Go()" value="通過js方法傳遞參數" />  
  23.   
  24.       
  25.     <!--第四種:通過form表單傳遞-->  
  26.     <form action="Handler1.ashx" method="get"><!--注意action里面的連接不能帶參數的-->>  
  27.         <input type="text" name="id" value="3" />  
  28.         <input type="text" name="name" value="abc" />  
  29.         <input type="submit" value="通過傳遞參數" />  
  30.     </form>  
  31. </body>  
  32. </html>  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM