function getContextPath() {var contextPath = document.location.pathname;var index =contextPath.substr(1).indexOf("/"); //这个地方可能有问题,要根据具体项目适当修改 contextPath = contextPath.substr(0,index+1);delete index;return contextPath; }以上这篇js 获取站点应用名的简单实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。