js中獲取專案路徑
阿新 • • 發佈:2018-12-21
//獲取專案路徑
var curRequestPath = window.document.location.href;
console.log("curRequestPath:" + curRequestPath);
//獲取專案請求路徑 /people/toGetPeopleList.action
var pathName = window.document.location.pathname;
console.log("pathName:" + pathName);
var ipAndPort = curRequestPath.indexOf(pathName);
console.log("ipAndPort:" + ipAndPort);
var localhostPath = curRequestPath.substring(0,ipAndPort);
console.log("localhostPath:" + localhostPath);
var projectName = pathName.substring(0,pathName.substr(1).indexOf('/')+1);
console.log("projectName:" + projectName);
basePath = localhostPath + projectName;