ASP如何取得当前页URL方法

本文提供了两种获取当前页面URL及其参数的方法。函数A通过遍历请求查询字符串来构建完整的URL,包括所有参数;函数B则直接利用服务器变量来组合生成当前页面的完整URL。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

'获取当前Url参数的函数A
 Private Function GetUrl()
  Dim ScriptAddress, M_ItemUrl, M_item
  ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME")) '取得当前地址
  M_ItemUrl = ""
  If (Request.QueryString <> "") Then
  ScriptAddress =  ScriptAddress & "?"
  For Each M_item In Request.QueryString
   If InStr(page,M_Item)=0 Then
    M_ItemUrl = M_ItemUrl & M_Item &"="& Server.URLEncode(Request.QueryString(""&M_Item&""))  & "&"
   End If
  Next
  end if
  GetUrl = ScriptAddress & M_ItemUrl
 End Function
'=============================


'获取当前页面URL的函数B

Function Cur_Url()    
  Domain_Name = LCase(Request.ServerVariables("Server_Name"))
  Page_Name = LCase(Request.ServerVariables("Script_Name"))
  Quary_Name = LCase(Request.ServerVariables("Quary_String"))
  If Quary_Name ="" Then
    Cur_Url = "http://"&Domain_Name&Page_Name
  Else
    Cur_Url = "http://"&Domain_Name&Page_Name&"?"&Quary_Name
  End If
End Function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝图

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值