ASP如何获取当前URL中最后一个斜杠前的地址
答案:4 悬赏:0
解决时间 2021-01-22 10:11
- 提问者网友:杀生予夺
- 2021-01-22 04:16
ASP如何获取当前URL中最后一个斜杠前的地址
最佳答案
- 二级知识专家网友:拜訪者
- 2021-01-22 05:04
<%
response.write(Cur_Url())
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"))
aaa = split(Page_Name,"/")
Page_Name = ""
for i = 1 to ubound(aaa)-1
Page_Name = Page_Name&"/"&aaa(i)
next
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
%>
以上代码,放在一个asp页面里运行即可得到结果!
如果有问题再找我!
response.write(Cur_Url())
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"))
aaa = split(Page_Name,"/")
Page_Name = ""
for i = 1 to ubound(aaa)-1
Page_Name = Page_Name&"/"&aaa(i)
next
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
%>
以上代码,放在一个asp页面里运行即可得到结果!
如果有问题再找我!
全部回答
- 1楼网友:荒野風
- 2021-01-22 08:19
可以实现的。帮你搞定 有没有报酬啊。。
- 2楼网友:怙棘
- 2021-01-22 07:11
我暂时保留我的看法!
- 3楼网友:廢物販賣機
- 2021-01-22 05:48
<%
dim u
u=request.ServerVariables("URL")
pos=instrRev(u,"/") '找到最右边的斜线位置
u=left(u,pos-1) '截取斜线左边的内容
response.write u '输出来看看
'以上是获取相对URL,如:/msg/messages/list
'如果要绝对URL,那就在前面加上域名:request.ServerVariables("SERVER_NAME"),自已拼接吧。
%>
dim u
u=request.ServerVariables("URL")
pos=instrRev(u,"/") '找到最右边的斜线位置
u=left(u,pos-1) '截取斜线左边的内容
response.write u '输出来看看
'以上是获取相对URL,如:/msg/messages/list
'如果要绝对URL,那就在前面加上域名:request.ServerVariables("SERVER_NAME"),自已拼接吧。
%>
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯