asp獲取當(dāng)前完整路徑(url)的函數(shù)代碼
有時(shí)候我么您需要獲取網(wǎng)址,端口、路徑文件名、參數(shù)等,這里就為大家分享一下這個(gè)函數(shù)代碼,需要的朋友可以參考下
函數(shù)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()
%>
函數(shù)2
<!--獲取當(dāng)前頁(yè)面路徑-->
<%
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
%>
使用的話肯定選擇第一個(gè),支持https的判斷。
如果是通過(guò)404頁(yè)面除非,這個(gè)是獲取不到的,需要結(jié)合js來(lái)實(shí)現(xiàn)
例如:
js頁(yè)面
<script>
var pathname = window.location.pathname;
location.replace("/do.asp?p="+pathname);
</script>
將路徑傳參給do.asp進(jìn)行處理
strpath=Request("p")
即可獲取404之前的頁(yè)面,然后進(jìn)行執(zhí)行操作即可,注意目錄權(quán)限。也可以放到404中處罰iframe進(jìn)行操作。
相關(guān)文章
ASP讀取Request.QueryString編碼的函數(shù)代碼
ASP讀取Request.QueryString編碼的函數(shù)代碼,學(xué)習(xí)asp的朋友可以參考下。2011-09-09
通過(guò)Response.Flush()實(shí)現(xiàn)下載失敗的解決方法
Response.Flush()實(shí)現(xiàn)對(duì)服務(wù)端文件的下載時(shí),會(huì)失敗,不能正常彈出IE下載框,通過(guò)測(cè)試發(fā)現(xiàn)時(shí)瀏覽器的安全設(shè)置問(wèn)題,如下操作便可解決2013-08-08
對(duì)于ASP編碼問(wèn)題的深入研究與最終解決方案
對(duì)于ASP編碼問(wèn)題的深入研究與最終解決方案...2007-05-05
ASP實(shí)現(xiàn)強(qiáng)制圖片下載函數(shù)
最近做的一個(gè)asp項(xiàng)目需要強(qiáng)制下載圖片,我在網(wǎng)上找了很多關(guān)于下載遠(yuǎn)程圖片的ASP代碼,但測(cè)試結(jié)果都不行。沒(méi)辦法只好自己操刀了,有什么紕漏的地方還請(qǐng)大家指出。2015-05-05
asp中格式化HTML函數(shù)代碼 SDCMS加強(qiáng)版
主要用來(lái)去除html中的script,iframe等html標(biāo)記,需要的朋友可以參考下。2011-01-01

