【js获取项目根路径】

来源:互联网 发布:有声照片软件 编辑:程序博客网 时间:2024/06/07 05:48

js获取项目根路径,如: http://localhost:8083/uimcardprj  

function getRootPath() {var curWwwPath = window.document.location.href;var pathName = window.document.location.pathname;var pos = curWwwPath.indexOf(pathName);var localhostPaht = curWwwPath.substring(0, pos);var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);return (localhostPaht + projectName);}


原创粉丝点击