原文出处:http://blog.csdn.net/xmq_666/article/details/7452710/
/**
* 创建人:xxx
* 创建时间:2012-04-12
* JS获取URL地址
* @returns 返回URL 如:http://localhost:8080
*/
function getURL(){
var curWwwPath = window.document.location.href;
//获取主机地址之后的目录,如: cis/website/meun.htm
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName); //获取主机地址,如: http://localhost:8080
var localhostPaht = curWwwPath.substring(0, pos); //获取带"/"的项目名,如:/cis
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
var rootPath = localhostPaht + projectName;
return rootPath;
}