获取浏览器 URL 地址相关的一些东西,如参数、路径等,用来进行相关操作。
地址示例:
- http://www.example.com:666/post/p/index.php?wd=abc&g=33#exampletitle
获取浏览器完整 URL 地址,返回
http://www.example.com:666/post/p/index.php?wd=abc&g=33#exampletitle
获取 URL 中完整的网站域名,返回
http://www.example.com:666
window.location.host 与 window.location.hostname 的区别在于端口号的获取。
获取 URL 中的域名「带端口」,返回
www.example.com:666
获取 URL 中的域名,返回
www.example.com
或者通过文档方式获取域名,返回
www.example.com
获取 URL 的协议,返回
http:
获取 URL 的端口,返回
666
获取 URL 的参数,返回
?wd=abc&g=33
获取 URL 的
# 后面内容,即描点,返回
#exampletitle
获取 URL 地址中的路径,返回
/post/p/index.php
获取完毕后,即可进行其他相关操作。
完毕!
该文章已关闭评论