码迷,mamicode.com
首页 > 其他好文 > 详细

location对象

时间:2016-06-02 13:32:19      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

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");

location对象

标签:

原文地址:http://www.cnblogs.com/yqlog/p/5552611.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!