Location 对象属性
Location 对象包含有关当前 URL 的信息。
Location 对象是 window 对象的一部分,可通过 window.Location 属性对其进行访问。
注意: 没有应用于Location对象的公开标准,不过所有浏览器都支持该对象。
文档:https://www.runoob.com/jsref/obj-location.html
1:host
获取一个网页的主机名和端口号
window.location.host

2:hostname
获取一个网页的主机名
window.location.hostname

3:href
返回完整的URL
window.location.href

4:pathname
返回的URL路径名。
window.location.pathname

5:port
获取URL服务器使用的端口号
window.location.port

6:protocol
window.location.protocol
protocol 属性是一个可读可写的字符串,可设置或返回当前 URL 的协议。

网友评论