国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

asp獲取當前完整路徑(url)的函數代碼

瀏覽:223日期:2022-06-04 18:58:55

有時候我么您需要獲取網址,端口、路徑文件名、參數等,這里就為大家分享一下這個函數代碼,需要的朋友可以參考下

函數1

<%
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
response.write GetUrl()
%>

函數2

<!--獲取當前頁面路徑--> 
<% 
dim str,host,url,keyword,full 
str="http://"; 
host = Request.ServerVariables("HTTP_HOST") 
url = Request.ServerVariables("PATH_INFO") "或url 
keyword = Request.ServerVariables("QUERY_STRING") 
if keyword <> "" then 
full = str&host&url&"?"&keyword 
else 
full = str&host&url 
end if 
session("url")=full 
%>

使用的話肯定選擇第一個,支持https的判斷。

如果是通過404頁面除非,這個是獲取不到的,需要結合js來實現

例如:

js頁面

<script>
var pathname = window.location.pathname;
location.replace("/do.asp?p="+pathname);
</script>

將路徑傳參給do.asp進行處理

strpath=Request("p")

即可獲取404之前的頁面,然后進行執行操作即可,注意目錄權限。也可以放到404中處罰iframe進行操作。

標簽: ASP
主站蜘蛛池模板: 青神县| 通化市| 固安县| 行唐县| 鹤峰县| 鹰潭市| 万荣县| 安阳市| 饶平县| 大厂| 惠水县| 茶陵县| 方正县| 南丹县| 理塘县| 清水河县| 云南省| 南宫市| 仲巴县| 宝山区| 河池市| 五指山市| 益阳市| 彩票| 芦山县| 华蓥市| 谷城县| 郴州市| 温宿县| 葫芦岛市| 烟台市| 长葛市| 绍兴县| 韩城市| 新田县| 德格县| 都兰县| 崇文区| 藁城市| 乌拉特前旗| 农安县|