4种get方法传参

< 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 >
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值