/ js 获取项目地址
var protocol = location.protocol;
var hostname = location.hostname;
var port = location.port; var pathname = location.pathname;
var basePath = protocol + “//” + hostname + “:” + port + pathname;
// 如果项目地址结尾有 index.jsp,去掉 index.jsp
if ( basePath.indexOf( ‘index.jsp’ ) != -1 ) {
basePath = basePath.substr( 0, basePath.indexOf( ‘index.jsp’ ) );
}
js 有 indexOf 函数,却没有 java 里那种 startsWith,endsWith 函数。
另外据说 js 中 startsWith,endsWith 函数不能在任何浏览器兼容
————————————————
版权声明:本文为CSDN博主「热带鱼2020」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/beguile/article/details/77366272