Asp转为根路径格式函数

来源:互联网 发布:advan仿真软件 编辑:程序博客网 时间:2024/06/09 17:34

 ' 转为根路径格式
Function RelativePath2RootPath(url)
 Dim sTempUrl
 sTempUrl = url
 If Left(sTempUrl, 1) = "/" Then
  RelativePath2RootPath = sTempUrl
  Exit Function
 End If

 Dim sWebEditorPath
 sWebEditorPath = Request.ServerVariables("SCRIPT_NAME")
 sWebEditorPath = Left(sWebEditorPath, InstrRev(sWebEditorPath, "/") - 1)
 Do While Left(sTempUrl, 3) = "../"
  sTempUrl = Mid(sTempUrl, 4)
  sWebEditorPath = Left(sWebEditorPath, InstrRev(sWebEditorPath, "/") - 1)
 Loop
 RelativePath2RootPath = sWebEditorPath & "/" & sTempUrl
End Function