1.获取主机名、路径、端口、协议

var hostName = window.location.hostname;

var pathName = window.location.pathname;

var port = window.location.port;

var protocal = window.location.protocol;

document.write("hostName"+hostName);

document.write("<br/>pathName:"+pathName);

document.write("<br/>port:"+port);

document.write("<br/>protocal:"+protocal);

 

2、重定向当前地址

window.location.assign("http://www.163.com");