DefiniteUrl asp將相對(duì)地址轉(zhuǎn)換為絕對(duì)地址的代碼
'函數(shù)名:DefiniteUrl
'作 用:將相對(duì)地址轉(zhuǎn)換為絕對(duì)地址
'參 數(shù):PrimitiveUrl ------要轉(zhuǎn)換的相對(duì)地址
'參 數(shù):ConsultUrl ------當(dāng)前網(wǎng)頁(yè)地址
'==================================================
Function DefiniteUrl(Byval PrimitiveUrl,Byval ConsultUrl)
Dim ConTemp,PriTemp,Pi,Ci,PriArray,ConArray
If PrimitiveUrl="" or ConsultUrl="" or PrimitiveUrl="$False$" or ConsultUrl="$False$" Then
DefiniteUrl="$False$"
Exit Function
End If
If Left(Lcase(ConsultUrl),7)<>"http://" Then
ConsultUrl= "http://" & ConsultUrl
End If
ConsultUrl=Replace(ConsultUrl,"\","/")
ConsultUrl=Replace(ConsultUrl,"://",":\\")
PrimitiveUrl=Replace(PrimitiveUrl,"\","/")
If Right(ConsultUrl,1)<>"/" Then
If Instr(ConsultUrl,"/")>0 Then
If Instr(Right(ConsultUrl,Len(ConsultUrl)-InstrRev(ConsultUrl,"/")),".")>0 then
Else
ConsultUrl=ConsultUrl & "/"
End If
Else
ConsultUrl=ConsultUrl & "/"
End If
End If
ConArray=Split(ConsultUrl,"/")
If Left(LCase(PrimitiveUrl),7) = "http://" then
DefiniteUrl=Replace(PrimitiveUrl,"://",":\\")
ElseIf Left(PrimitiveUrl,1) = "/" Then
DefiniteUrl=ConArray(0) & PrimitiveUrl
ElseIf Left(PrimitiveUrl,2)="./" Then
PrimitiveUrl=Right(PrimitiveUrl,Len(PrimitiveUrl)-2)
If Right(ConsultUrl,1)="/" Then
DefiniteUrl=ConsultUrl & PrimitiveUrl
Else
DefiniteUrl=Left(ConsultUrl,InstrRev(ConsultUrl,"/")) & PrimitiveUrl
End If
ElseIf Left(PrimitiveUrl,3)="../" then
Do While Left(PrimitiveUrl,3)="../"
PrimitiveUrl=Right(PrimitiveUrl,Len(PrimitiveUrl)-3)
Pi=Pi+1
Loop
For Ci=0 to (Ubound(ConArray)-1-Pi)
If DefiniteUrl<>"" Then
DefiniteUrl=DefiniteUrl & "/" & ConArray(Ci)
Else
DefiniteUrl=ConArray(Ci)
End If
Next
DefiniteUrl=DefiniteUrl & "/" & PrimitiveUrl
Else
If Instr(PrimitiveUrl,"/")>0 Then
PriArray=Split(PrimitiveUrl,"/")
If Instr(PriArray(0),".")>0 Then
If Right(PrimitiveUrl,1)="/" Then
DefiniteUrl="http:\\" & PrimitiveUrl
Else
If Instr(PriArray(Ubound(PriArray)-1),".")>0 Then
DefiniteUrl="http:\\" & PrimitiveUrl
Else
DefiniteUrl="http:\\" & PrimitiveUrl & "/"
End If
End If
Else
If Right(ConsultUrl,1)="/" Then
DefiniteUrl=ConsultUrl & PrimitiveUrl
Else
DefiniteUrl=Left(ConsultUrl,InstrRev(ConsultUrl,"/")) & PrimitiveUrl
End If
End If
Else
If Instr(PrimitiveUrl,".")>0 Then
If Right(ConsultUrl,1)="/" Then
If right(LCase(PrimitiveUrl),3)=".cn" or right(LCase(PrimitiveUrl),3)="com" or right(LCase(PrimitiveUrl),3)="net" or right(LCase(PrimitiveUrl),3)="org" Then
DefiniteUrl="http:\\" & PrimitiveUrl & "/"
Else
DefiniteUrl=ConsultUrl & PrimitiveUrl
End If
Else
If right(LCase(PrimitiveUrl),3)=".cn" or right(LCase(PrimitiveUrl),3)="com" or right(LCase(PrimitiveUrl),3)="net" or right(LCase(PrimitiveUrl),3)="org" Then
DefiniteUrl="http:\\" & PrimitiveUrl & "/"
Else
DefiniteUrl=Left(ConsultUrl,InstrRev(ConsultUrl,"/")) & "/" & PrimitiveUrl
End If
End If
Else
If Right(ConsultUrl,1)="/" Then
DefiniteUrl=ConsultUrl & PrimitiveUrl & "/"
Else
DefiniteUrl=Left(ConsultUrl,InstrRev(ConsultUrl,"/")) & "/" & PrimitiveUrl & "/"
End If
End If
End If
End If
If Left(DefiniteUrl,1)="/" then
DefiniteUrl=Right(DefiniteUrl,Len(DefiniteUrl)-1)
End if
If DefiniteUrl<>"" Then
DefiniteUrl=Replace(DefiniteUrl,"http://","/")
DefiniteUrl=Replace(DefiniteUrl,":\\","://")
Else
DefiniteUrl="$False$"
End If
End Function
相關(guān)文章
循環(huán)取值Request.QueryString的用法
2008-01-01通過(guò)asp程序來(lái)創(chuàng)建access數(shù)據(jù)庫(kù)
access數(shù)據(jù)庫(kù)屬于“文件型數(shù)據(jù)庫(kù)”,創(chuàng)建時(shí)需要指定它要使用的文件2009-06-06Microsoft VBScript 編譯器錯(cuò)誤 錯(cuò)誤原因 代碼大全
這篇文章主要介紹了Microsoft VBScript 編譯器錯(cuò)誤 錯(cuò)誤原因 代碼大全,需要的朋友可以參考下2015-07-07asp中利用xmlhttp抓取網(wǎng)頁(yè)內(nèi)容的代碼
抓取網(wǎng)頁(yè)。偶要實(shí)現(xiàn)實(shí)實(shí)更新天氣預(yù)報(bào)。利用了XMLHTTP組件,抓取網(wǎng)頁(yè)的指定部分,其實(shí)很多的小偷程序要更好用2012-10-10微信公眾號(hào)可通過(guò)現(xiàn)金紅包接口發(fā)放微信支付現(xiàn)金紅包(附開發(fā)教程)
這篇文章主要介紹了微信公眾號(hào)可通過(guò)現(xiàn)金紅包接口發(fā)放微信支付現(xiàn)金紅包的相關(guān)資料,需要的朋友可以參考下2016-09-09asp+Access通用的自動(dòng)替換數(shù)據(jù)庫(kù)中的字符串
幾年前寫的一個(gè)腳本,可以自動(dòng)進(jìn)行整庫(kù)的數(shù)據(jù)替換。2008-06-06ASP中保留小數(shù)點(diǎn)后兩位數(shù)的方法(使用FormatNumber)
這篇文章主要介紹了ASP中保留小數(shù)點(diǎn)后兩位數(shù)的方法,使用FormatNumber函數(shù)實(shí)現(xiàn),需要的朋友可以參考下2014-06-06