js获取项目根路径

 

  //js获取项目根路径
    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);
    }

 

posted @ 2015-12-06 01:15  Tom1997  阅读(1182)  评论(0编辑  收藏  举报