喜欢本站并加入收藏
首 页 电脑学园 技术文档 图形图像 办公应用 网页设计 管理资料 PPT模板 方案合同
 位置: 北方教程网 >> 网页设计 >> Asp专题 >> 正文
   ASP编程中的路径格式转换函数及相关实例
ASP编程中的路径格式转换函数及相关实例
[ 作者:佚名   来源:网络整理   点击数:   更新时间:2007-6-22 ]
<%
' 转为根路径格式
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

' 根路径转为带域名全路径格式
Function RootPath2DomainPath(url)
  Dim sHost, sPort
  sHost = Split(Request.ServerVariables("SERVER_PROTOCOL"), "/")(0) & "://" & Request.ServerVariables("HTTP_HOST")
  sPort = Request.ServerVariables("SERVER_PORT")
  If sPort <> "80" Then
    sHost = sHost & ":" & sPort
  End If
  RootPath2DomainPath = sHost & url
End Function


response.Write("TestEx.<br />")
response.Write("转为根路径格式:"&RelativePath2RootPath("myfolder/ggg.gif"))
response.Write("<br />")
response.Write("根路径转为带域名全路径格式:"&RootPath2DomainPath("/myfolder/ggg.gif"))
response.Write("输出当前程序所在的目录:"&RelativePath2RootPath(""))
%>
上一篇文章: 解读ASP、PHP、JSP的特点和优势 下一篇文章: ASP加密和解密类源代码
打印此文  收藏此页  关闭窗口  返回顶部
 相关文章  热点文章
 · 利用CSS改进网站设计的小技巧
 · Dreamweaver快捷操作技巧集锦
 · 使用Dreamweaver架设网站简明教程
 · 网页设计制作过程中常用的几个代码技巧
 · 高效使用CSS编码的方法
 
热点图文
教你节省Vist...
使用Windows ...
 · 远程管理Web服务器的方法技巧
 · Win Vista系统自带IIS7.0设置详解...
 · 详解Windows系统IIS6.0功能及应用...
 · 服务器集群系统实现方法及案例分...
 · IIS服务器实现asp,cgi和php+mysq...
 · IIS下SQL Server数据库安全设置技...
推 荐 阅 读
巧用Photosho...
Photoshop鼠绘...
 · Fireworks制作旋转的漂亮gif动画...
 · Photoshop制作都市满天繁星
 · Fireworks制作Menu按钮
 · 巧用Photoshop制作喜迎奥运壁纸
 · 巧用Photoshop钢笔工具绘制彩色美...
 · Photoshop制作浪漫动感花朵
 设为首页 - 加入收藏 - 关于本站 - 联系我们 - 广告合作 - 友情链接 - 在线交流 - 
CopyRight© 2006-2009 Eduai.Com All Rights Reserved
在线交流 QQ:524152258 辽ICP备07001851号
免责声明:本站部分资源来自网络,如有侵犯您的版权请通知,我们立即删除。