现在的位置: 首页 > 综合 > 正文

js 获取系统根目录

2017年12月25日 ⁄ 综合 ⁄ 共 438字 ⁄ 字号 评论关闭

//获取根目录(域名+工程名)
var getBasePath = function () {
       var curWwwPath = window.document.location.href;
       console.info(curWwwPath);
       var pathName = window.document.location.pathname;
       console.info(pathName);
       var pos = curWwwPath.indexOf(pathName);
       console.info(pos);
       var localhostPaht = curWwwPath.substring(0, pos);
       console.info(localhostPaht);
       var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
       console.info(projectName);
       return (localhostPaht + projectName);
}

抱歉!评论已关闭.