javascript获取web应用根目录的方法
更新时间:2014年02月12日 11:05:55 作者:
这篇文章主要介绍了javascript获取web应用根目录的方法,需要的朋友可以参考下
复制代码 代码如下:
<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>
相关文章
jacascript DOM节点——元素节点、属性节点、文本节点
这篇文章主要介绍了jacascript DOM节点——元素节点、属性节点、文本节点,需要的朋友可以参考下2017-04-04


最新评论