//获取当前网址 var curWwwPath=window.document.location.href; alert(curWwwPath); //http://localhost:8080/Test/index.jsp //获取主机地址之后的目录 var pathName=window.document.location.pathname; alert(pathName); // /Test/index.jsp //获取主机地址 var pos=curWwwPath.indexO…
代码如下: //获取当前网址,如: var curWwwPath=window.document.location.href; //获取主机地址之后的目录如:/Tmall/index.jsp var pathName=window.document.location.pathname; var pos=curWwwPath.indexOf(pathName); //获取主机地址,如://localhost:8080 var localhostPaht=curWwwPath.substring(0…