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

4种get传参方式javascript

<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  
    <title></title>  
    <script type="text/javascript">  
        function Go() {  
            window.location.href="localhost:21811/Handler1.ashx?id=1&name='abc'"  
        }  
    </script>  
</head>  
<body>  
  
   <!--//参数传递的几种形式-->  
    <!--第一种:直接在URL后面加参数:-->  
    localhost:21811/Handler1.ashx?id=1&name="abc"  
  
  
    <!--第二种:用超连接的方法传递参数:当点击超连接的时候,首先会跳转到localhost:21811/Handler1.ashx页面,而后还会传递id 和name 两个参数过去-->  
    <a href="localhost:21811/Handler1.ashx?id=1&name='abc'">超连接传递参数</a></body>  
  
    <!--第三种:经过js方法传递:用户点击这个button按钮,触发onClick事件,执行Go()方法,跳转到localhost:21811/Handler1.ashx页面,同时传递了id,和name两个参数过去-->  
    <input type="button" onclick="Go()" value="经过js方法传递参数" />  
  
      
    <!--第四种:经过form表单传递-->  
    <form action="Handler1.ashx" method="get"><!--注意action里面的链接不能带参数的-->>  
        <input type="text" name="id" value="3" />  
        <input type="text" name="name" value="abc" />  
        <input type="submit" value="经过传递参数" />  
    </form>  
</body>  
</html>  
相关文章
相关标签/搜索