美文网首页前端学习之路
js中的location各种属性

js中的location各种属性

作者: Light_shallow | 来源:发表于2018-12-17 14:39 被阅读0次

一、hash设置或返回从井号 (#) 开始的 URL(锚)。

URL 是: http://example.com:1234/test.htm#part2

location.hash-------------#part2

二、host设置或返回主机名和当前 URL 的端口号。

URL 是: http://example.com:1234/test.htm#part2

location.host------------example.com:1234

三、hostname设置或返回当前 URL 的主机名。

URL 是: http://example.com:1234/test.htm#part2:

location.hostname------------example.com

四、href设置或返回完整的 URL。

URL 是: http://example.com:1234/test.htm#part2:

location.href-------------http://example.com:1234/test.htm#part2

五、pathname设置或返回当前 URL 的路径部分。

URL 是: http://example.com:1234/test/test.htm#part2:

location.pathname-------------/test/test.htm

六、port设置或返回当前 URL 的端口号。

URL 是: http://example.com:1234/test.htm#part2:

location.port-------------1234

七、protocol设置或返回当前 URL 的协议。

URL 是: http://example.com:1234/test.htm#part2:

location.protocol-------------http:

八、search设置或返回从问号 (?) 开始的 URL(查询部分)。

URL 是: http://www.w3school.com.cn/tiy/t.asp?f=hdom_loc_search

location.search-------------?f=hdom_loc_search

相关文章

网友评论

    本文标题:js中的location各种属性

    本文链接:https://www.haomeiwen.com/subject/czashqtx.html