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>