主题:  javascript 编码问题(请大家帮忙)

brucelee

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/10/22 10:37:49
#12002/9/3 13:54:02
function UrlPath()
{
    this.urlPath="";
    this.getPath=getPath;
}

function getPath(local)
{
    if ( local )
    {
        this.urlPath=document.location.pathname;
        this.urlPath=this.urlPath.substr(1,this.urlPath.length);
        this.urlPath=this.urlPath.substr(0,1)+":"+this.urlPath.substr(2,this.urlPath.length);
    }
    else
    {
        this.urlPath=document.location.protocol+"//"+document.location.hostame+    
            document.location.pathname;
    }
    return this.urlPath;
}


问题是这样的 当我在其它页面引用它是,只有主页能引用,其它页面引用不了,该怎么办

编辑历史:[这消息被brucelee编辑过(编辑时间2002-09-03 13:57:35)]
[这消息被brucelee编辑过(编辑时间2002-09-03 13:59:53)]


brucelee

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/10/22 10:37:49
#22002/9/3 14:37:05
为什么没有帮我呀!



5D荣誉斑竹

职务:普通成员
等级:2
金币:10.0
发贴:622
注册:2001/10/21 13:06:17
#32002/9/3 16:51:08
可以把js脚本保存为*.js文件

然后在需要调用这个函数的网页中加入




NudeAngel

职务:普通成员
等级:3
金币:10.0
发贴:793
注册:2002/1/29 14:14:58
#42002/9/3 17:19:53
你得把脚本另存为外部.js文件才可以重复引用,不然每一页都得写上那一大段代码。



brucelee

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/10/22 10:37:49
#52002/9/3 19:28:35
不这就是外部脚本,我是在其他页面引用它是,出现得错误!
我在其他页面引用了urlpath
但是出现了只有主页,也就是在IIS里定义的主页才能调用,其他页面调用不了,所以我想改一下,但不知道怎么改?



brucelee

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/10/22 10:37:49
#62002/9/4 8:29:04
是我 没写明白吗?



brucelee

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/10/22 10:37:49
#72002/9/4 10:50:10
5d的高手很多
怎么会没人呢?是我说的不明白吗?



brucelee

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/10/22 10:37:49
#82002/9/4 11:37:44
我要一直顶下去!!!
版主不要说我灌水,我也是没办法!



snipergz

职务:普通成员
等级:1
金币:0.0
发贴:30
注册:2001/12/13 12:32:02
#92002/9/4 14:09:40
会不会调用脚本时路径有错?



brucelee

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/10/22 10:37:49
#102002/9/4 16:49:33
snipergz在上个帖子中说
引用:
会不会调用脚本时路径有错?


对我也是这么想的,但是一直没找到错误的地方!



海麟

职务:普通成员
等级:1
金币:0.0
发贴:26
注册:2002/7/11 1:01:22
#112002/9/5 19:32:52
肯定是路径不对?写绝对的吧!



5D荣誉斑竹

职务:普通成员
等级:5
金币:10.0
发贴:3292
注册:2001/5/24 10:01:29
#122002/9/6 3:01:51
代码不全

没看懂什么意思,麻烦写一下注释

注意大小写



5D荣誉斑竹

职务:普通成员
等级:2
金币:10.0
发贴:622
注册:2001/10/21 13:06:17
#132002/9/6 10:34:00
function UrlPath()
{
this.urlPath="";
this.getPath=getPath;
}
function getPath(local)
{
if ( local )
{
this.urlPath=document.location.pathname;
this.urlPath=this.urlPath.substr(1,this.urlPath.length);
this.urlPath=this.urlPath.substr(0,1)+":"+this.urlPath.substr(2,this.urlPath.length);
}
else
{
this.urlPath=document.location.protocol+"//"+document.location.hostname+
document.location.pathname;
}
return this.urlPath;
}



brucelee

职务:普通成员
等级:1
金币:0.0
发贴:58
注册:2001/10/22 10:37:49
#142002/9/6 15:55:25
代码的确不全,因为我不能贴出完整的代码?因为这涉及到我们公司的商业秘密!:(对不起
而且我觉得主要问题出在这里!
引用页面的调用是:

var urlPath=new UrlPath()
HomePath=urlPath.getPath(0)
HomePath=HomePath.substr(0, HomePath.length-12)

只能在一个页面调用,其它页面不能用。
而且这个项目的所有程序不是我写的,写程序的人已经走了,把这些都交给我了,所以我也很晕!!!!!!

请大家帮忙看看。