// 获取当前网址,如:http://localhost:8080/xxxx/xxx.html
var curWwwPath = window.document.location.href;
// 获取主机地址之后的目录,如: xxx/xxx.html
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
// 获取主机地址,如: http://localhost:8080
var localhostPath = curWwwPath.substring(0, pos);
js获取主机地址
最新推荐文章于 2024-04-05 12:54:13 发布