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

location对象

时间:2018-12-01 20:04:55      阅读:582      评论:0      收藏:0      [点我收藏+]

标签:跳转   内容   端口号   www.   protocol   搜索   arch   历史   http   

//对象中的属性和方法
//location 对象
console.log(window.location);


//地址栏上#及后面的内容
console.log(window.location.hash);
//主机及端口号
console.log(window.location.host);
//主机名
console.log(window.location.hostname);
//文件的路径----相对路径
console.log(window.location.pathname);
//端口号
console.log(window.location.port);
//协议
console.log(window.location.protocol);
//搜索的内容
console.log(window.location.search);


//设置跳转的页面地址
location.href="http://www.baidu.com";//属性-----
location.assign("http://www.baidu.com");//方法
location.reload();//重新加载
location.replace("http://www.baidu.com");//没有历史记录----不能返回原页面

location对象

标签:跳转   内容   端口号   www.   protocol   搜索   arch   历史   http   

原文地址:https://www.cnblogs.com/lujieting/p/10050467.html

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