jquery 动态获得主机地址

时间:2023-03-08 22:12:11
 var curWwwPath=window.document.location.href;
     alert("curWwwPath"+curWwwPath);   curWwwPath    http://localhost:8084/weixin/wxFfanApply.htm?method=preSubPage
     var pathName=window.document.location.pathname;
     alert("pathName"+pathName);            pathName      /weixin/wxFfanApply.htm
     var pos=curWwwPath.indexOf(pathName);
     alert("pos"+pos);                   pos     21
     var localhostPaht=curWwwPath.substring(0,pos);
     alert("localhostPaht"+localhostPaht);   localhostPaht    http://localhost:8084