有的时候需要在js文件中获取项目的路径,这时候就需要使用jquery获取路径的方法:
jquery方法中调用
getRootPath()+"static/html/projecthelp.html"
//获取项目访问路径
function getRootPath() {
var pathName = window.location.pathname.substring(1);
var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));
return window.location.protocol + '//' + window.location.host + '/' + webName + '/';
}