ASP获取当前页URL

 

 ASP获取当前页URL,特别是前URL一般都含有参数,若无参数,则只用“Request.ServerVariables("SCRIPT_NAME")”即可,但含参数的URL如何得到呢?用如下函数实现:

 

Function GetUrl() 
On Error Resume Next 
Dim strTemp 
If LCase(Request.ServerVariables("HTTPS")) = "off" Then 
strTemp = "http://" 
Else 
strTemp = "https://" 
End If 
strTemp = strTemp & Request.ServerVariables("SERVER_NAME") 
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT") 
strTemp = strTemp & Request.ServerVariables("URL") 
If Trim(Request.QueryString) <> "" Then strTemp = strTemp & "?" & Trim(Request.QueryString) 
GetUrl = strTemp 
End Function
调用:
<%
Dim   curl
curl=GetUrl()
Response.write(curl)
%>
posted @ 2010-08-09 11:42  肚肚  阅读(342)  评论(0编辑  收藏  举报