很多人喜欢把一个网站中相同的部分象是统一的页面logo,版权声明等做成一个过程,然后放到一个include文件中,这样所有的页面就都可以使用,但这样就存在一个问题,如果使用绝对路径,移植时就很麻烦,如开发试一般不使用域名,而实际使用时就要进行改动,但如果不用绝对路径的话,根目录和子目录中调动这个过程的时候就有个路径问题,举个例子,图片都放在images目录中,在根目录中调用时用"images/xxx.gif" ,在一级子目录中就要用"../images/xxx.gif"...,那么怎么解决这个问题呢,看下面这个函数
'----------------------------------------------------------------------------------
'
' function name : GetPaht()
'
' description: 解决不同目录中的路径问题
'
' parameters: none
'
' date: 2000/3/25
'
' author: LiuYunpeng
'
' History: 2000/3/25 version 1.0
'
'---------------------------------------------------------------------------------
function GetPath()
dim m_intLoop , m_strBaseDIr
for m_intLoop = 2 to ubound(split(Request.ServerVariables ("SCRIPT_NAME"),"/" )) - 1
m_strBaseDir = m_strBaseDir + "../"
next
GetPath = m_strBaseDir
end function
这是就可以这样写图片路径
<img src="&GetPath()+'Images'&"/xxx.gif>,这样的话无论在多少级子目录中都不用担心路径问题了。
'----------------------------------------------------------------------------------
'
' function name : GetPaht()
'
' description: 解决不同目录中的路径问题
'
' parameters: none
'
' date: 2000/3/25
'
' author: LiuYunpeng
'
' History: 2000/3/25 version 1.0
'
'---------------------------------------------------------------------------------
function GetPath()
dim m_intLoop , m_strBaseDIr
for m_intLoop = 2 to ubound(split(Request.ServerVariables ("SCRIPT_NAME"),"/" )) - 1
m_strBaseDir = m_strBaseDir + "../"
next
GetPath = m_strBaseDir
end function
这是就可以这样写图片路径
<img src="&GetPath()+'Images'&"/xxx.gif>,这样的话无论在多少级子目录中都不用担心路径问题了。
上一篇:asp中ADO的优化
下一篇:ASP技巧TOP 10(一)
- 关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 管理登陆
- Copyright © 2003-2007 ZhuYe123.COM. All Rights Reserved . 粤ICP备05072659号
- 致力于中国个人网站发展,我们一直在努力!