location对象

1、location对象

location对象也属于windaow对象的一部分 所以除了使用location外,还可以使用window.location

例如:https://hrointerview.51job.com/interview/inviteassess?inviteid=2AA40AD472BEBEAF&jobseekid=51897793#1

属性:

href                   https://hrointerview.51job.com/interview/inviteassess?inviteid=2AA40AD472BEBEAF&jobseekid=51897793#1 (完整URL)

protocol             https:(协议)

host                   hrointerview.51job.com (主机名+端口号 如果端口号为80则不显示)

hostname          hrointerview.51job.com (主机名)

pathname          /interview/inviteassess(路径)

port                    端口号

search               ?inviteid=2AA40AD472BEBEAF&jobseekid=51897793(参数)

harsh                  #1(锚)

 

 

方法(都可用于刷新页面)

assign(url)      加载一个新的文档

reload(boolean)   false:从客户端缓存中获取当前页   true:从服务器端重新获取

replace(url)   替换缓存在客户端的地址

其他刷新页面方法

history.go(0)     //history.back() history.forward() history.go(-1)  history.go(1)

location.replace(document.referrer)     //返回并刷新页面   document.referrer 前一个URL地址

location=location

 

 

posted @ 2018-01-16 17:54  Mary哎呀小龙  阅读(172)  评论(0编辑  收藏  举报