js 获取当前web应用的前后文路径

js 获取当前web应用的上下文路径function getWebRootPath() {??? var webrootdocument.location.href???

js 获取当前web应用的上下文路径

function getWebRootPath() {
??? var webroot=document.location.href;
??? webroot=webroot.substring(webroot.indexOf('//')+2,webroot.length);
??? webroot=webroot.substring(webroot.indexOf('/')+1,webroot.length);
??? webroot=webroot.substring(0,webroot.indexOf('/'));
??? var rootpath="/"+webroot;
??? return rootpath;
}