Jquery中获取上下文路径contextPath

function getContextPath(){
    var pathName = document.location.pathname;
    var index = pathName.substr(1).indexOf("/");
    var result = pathName.substr(0,index+1);
    return result;
}

var contextPath = getContextPath();

 

//这个是项目名称

alert(contextPath);

你可能感兴趣的:(Jquery中获取上下文路径contextPath)