function getRootPath(){
    //获取当前网址,如: http://localhost:8088/test/test.jsp
    var curPath=window.document.location.href;
    //获取主机地址之后的目录,如: test/test.jsp
    var pathName=window.document.location.pathname;
    var pos=curPath.indexOf(pathName);
    //获取主机地址,如: http://localhost:8088
    var localhostPaht=curPath.substring(0,pos);
    //获取带"/"的项目名,如:/test
    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
    return(localhostPaht+projectName);
}

 

相关文章:

  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2021-12-08
  • 2021-11-12
  • 2021-11-27
猜你喜欢
  • 2021-09-01
  • 2022-12-23
  • 2021-11-29
  • 2021-11-29
  • 2021-12-01
  • 2021-07-29
相关资源
相似解决方案