展会信息港展会大全

javascript获取web应用根目录的方法
来源:互联网   发布日期:2016-03-24 20:08:26   浏览:2137次  

导读:这篇文章主要介绍了javascript获取web应用根目录的方法,需要的朋友可以参考下代码如下:<script>function getRootPath(){var strFull...

这篇文章主要介绍了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>

赞助本站

人工智能实验室

相关热词: 开发 编程 android

相关内容
AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港