location的用法

 1 <!doctype html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <title></title>
 6 </head>
 7 <body>
 8 <script>
 9     console.log(location.href);
10     console.log(location.protocol);
11     console.log(location.host);
12     console.log(location.port);
13     console.log(location.pathname);
14 //    问号后面的内容,包括问号
15  console.log(location.search);
16 //    #号后面的内容,包括#
17     console.log(location.hash);
18 //    加载新页面;不知道与window.open()的区别;
19     location.assign("http://www.baidu.com")
20 //    重新刷新当前页面
21     location.reload()
22 </script>
23 </body>
24 </html>
坚持下去就能成功
原文地址:https://www.cnblogs.com/suoking/p/4961743.html