- hash,返回一个url的一个锚部分。返回一个 URL 的主要部分。假设当前的 URL 是 http://www.runoob.com/test.htm#PART2:输出#part2
- host,返回一个url的主机名和端口号。document.write(location.host);返回www.baidu.com
- hostname,返回主机名。document.write(location.hostname);返回www.baidu.com
- href,返回完整的url,document.write(location.href);返回https://www.runoob.com/jsref/prop-loc-href.html
- pathname,返回url的路径部分,document.write(location.pathname);返回/jsref/prop-loc-pathname.html
- port,返回一个URL服务器使用的端口号,document.write(location.port);返回80
- protocol,返回当前url协议,document.write(location.protocol);返回https:
- search,返回url的查询部分,document.write(location.search);返回?email=someone@example.com
window.location对象的各个属性使用
最新推荐文章于 2023-03-10 20:51:10 发布