javascript获取项目根目录带项目名

javascript获取项目根目录带项目名

//获取当前网址,如: http://localhost:8080/chenThree/jspPage/pages/projectImplementation.html
var curWwwPath=window.document.location.href; 									
//获取主机地址之后的目录如:/chenThree/jspPage/pages/projectImplementation.html 
var pathName=window.document.location.pathname; 
var pos=curWwwPath.indexOf(pathName); 									
//获取主机地址,如: http://localhost:8080/chenThree
var localhostPaht=curWwwPath.substring(0,pos); 									
//获取带"/"的项目名,如:/chenThree
var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); 




猜你喜欢

转载自blog.csdn.net/hello_mr_anan/article/details/78769616
今日推荐