参数传递的四种形式----- URL,超链接,js,form表单

  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.     <a 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>  
原文地址:https://www.cnblogs.com/jquery37/p/4666382.html