6.location.html 745 B

123456789101112131415161718192021
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. //hash 设置或返回从井号 (#) 开始的 URL(锚)
  11. //host 设置或返回主机名和当前 URL 的端口号
  12. //hostname 设置或返回当前 URL 的主机名
  13. //href 设置或返回完整的 URL
  14. //pathname 设置或返回当前 URL 的路径部分
  15. //port 设置或返回当前 URL 的端口号
  16. //protocol 设置或返回当前 URL 的协议
  17. //search 设置或返回从问号 (?) 开始的 URL(查询部分)
  18. console.log(location.port)
  19. </script>
  20. </body>
  21. </html>