JS 如何取得网站或者虚拟目录的根地址?
如果建立的是应用程序或者虚拟目录,此句为网站的根目录(网上直接拿下的,可以改改)
在80端口建立一个虚拟目录:Test  我要的结果为:http://xxxx:80/Test
function getRootPath(){ 
var strFullPath=window.document.location.href; 
var strPath=window.document.location.pathname; 
var pos=strFullPath.indexOf(strPath); 
var prePath=strFullPath.substring(0,pos); 
var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1); 
return(prePath+postPath);
}如果建立的是网站类型的站点,此句为网站的根目录
在80端口建立一个网站类型的站点:Test  我要的结果为:http://xxxx:80
webPath: window.location.protocol + "//" + window.location.host
该怎么处理呢?我现在就是想JS取得根目录.