javascript获取host

document.writeln(location.protocol);
document.writeln(location.origin);  //包括端口号
document.writeln(location.host);    //不包括端口号
document.writeln(location.port);         //默认为80的就为空
document.writeln(location.pathname);
 
<a href="<%=location.origin%>/membership/member/detail?member_id=<%= item.member_id %>">
原文地址:https://www.cnblogs.com/Brittany-yan/p/5382661.html