location对象
常用属性
| 属性名 | 描述 |
|---|---|
location.href |
获取或设置整个URL |
location.hostname |
主机名 |
location.port |
端口号,若没有写返回空字符串 |
location.pathname |
路径部分 |
location.search |
查询部分 |
location.hash |
片段字符串,#后面内容 |
常用方法
| 方法名 | 描述 |
|---|---|
location.assign(URL) |
跟href一样,可以跳转页面(也称为重定向页面) |
location.replace(URL) |
替换当前页面,因为不被记录历史,所以不能后退页面 |
location.reload(flag) |
重新加载页面,相当于刷新按钮或者F5,如果参数为true强制刷新ctrk+f5 |

Comments NOTHING