javascript获取web应用根目录的方法

时间:2014-02-12    点击:73   
复制代码 代码如下:

<script>
function getRootPath(){
var strFullPath=window.document.location.href;
var strPath=window.document.location.pathname;
var pos=strFullPath.indexOf(strPath);
var prePath=strFullPath.substring(0,pos);
var postPath=strPath.substring(0,strPath.substr(1).indexOf(‘/')+1);
return(prePath+postPath);
}
var webpath=getRootPath(); //webpath就是目录路径变量
</script>
JavaScript中创建对象和继承示例解读
javascript实现文本域写入字符时限定字数
js 绑定键盘鼠标事件示例代码
动态加载jquery库的方法
jquery实现页面图片等比例放大缩小功能
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved