ASP获取当前页URL
ASP获取当前页URL,特别是前URL一般都含有参数,若无参数,则只用“Request.ServerVariables("SCRIPT_NAME")”即可,但含参数的URL如何得到呢?用如下函数实现:'=========================
'获取当前Url参数的函数
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
'=============================
另外,可以写成一个函数
Function Cur_Url() '获取当前页面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
- 来源:转载
- 版权声明:请尊重原作者的版权,转载请注明作者、出处(老吧)。
- 本文链接地址:http://www.lao8.org/html/8/2008-1-18/geturl/
- 文章名:ASP获取当前页URL




