function getRootPath (){ //Get the current URL, such as: http://localhost:8090/jobservice/service/meun.jsp var curWwwPath=window.document.location.href ; //Get the directory after the host address, such as: jobservice/service/menu.jsp var pathName =window.document.location.pathname ; var pos=curWwwPath.indexOf (pathName) ; //Get the host address, such as: http://localhost:8090 var localhostPaht =curWwwPath.substring ( 0 , pos) ; //Get the project name with "/", such as: /jobservice var projectName=pathName. substring ( 0 , pathName.substr(1).indexOf('/')+1); return(localhostPaht+projectName); }
js gets the root path of the web
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326013105&siteId=291194637
Recommended
Ranking