首页  >  文章  >  web前端  >  javascript获取web应用根目录的方法_javascript技巧

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

WBOY
WBOY原创
2016-05-16 17:00:181227浏览
复制代码 代码如下:

<script> <BR>function getRootPath(){ <BR>var strFullPath=window.document.location.href; <BR>var strPath=window.document.location.pathname; <BR>var pos=strFullPath.indexOf(strPath); <BR>var prePath=strFullPath.substring(0,pos); <BR>var postPath=strPath.substring(0,strPath.substr(1).indexOf(‘/')+1); <BR>return(prePath+postPath); <BR>} <BR>var webpath=getRootPath(); //webpath就是目录路径变量 <BR></script>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn