1. <body>
2.     <button onclick="alert(location.href)">弹出当前地址</button>
3.     <button onclick="location.href = 'https://www.baidu.com'">href</button>
4.     <button onclick="location.assign('https://www.baidu.com')">assign</button>
5.     <button onclick="location.reload()">刷新</button>
6.     <button onclick="location.replace('http://www.163.com')">replace</button>
7.     <script>
8.         // location.replace 打开一个新的页面 但不会增加新的历史记录
9.         //                  反而会替换当前历史记录项 用户无法返回原始页面
10.         // location.reload() 重新加载当前页面
11.         // location.assign 加载新的文档
12.         // location.href 赋值可以打开
13.         // window.location.href 对象用于获取当前页面的地址 并把浏览器重定向到新的页面
14.
15.         console.dir(document.location)
16.         console.dir(window.location)
17.
18.     </script>
19. </body>