location对象

来源:互联网 发布:淘宝品牌授权怎么弄啊 编辑:程序博客网 时间:2024/05/16 13:06
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");

0 0