一、hash設(shè)置或返回從井號 (#) 開始的 URL(錨)。
URL 是: http://example.com:1234/test.htm#part2
location.hash-------------#part2
二、host設(shè)置或返回主機(jī)名和當(dāng)前 URL 的端口號。
URL 是:?http://example.com:1234/test.htm#part2
location.host------------example.com:1234
三、hostname設(shè)置或返回當(dāng)前 URL 的主機(jī)名。
URL 是:?http://example.com:1234/test.htm#part2:
location.hostname------------example.com
四、href設(shè)置或返回完整的 URL。
URL 是:?http://example.com:1234/test.htm#part2:
location.href-------------http://example.com:1234/test.htm#part2
五、pathname設(shè)置或返回當(dāng)前 URL 的路徑部分。
URL 是:?http://example.com:1234/test/test.htm#part2:
location.pathname-------------/test/test.htm
六、port設(shè)置或返回當(dāng)前 URL 的端口號。
URL 是:?http://example.com:1234/test.htm#part2:
location.port-------------1234
七、protocol設(shè)置或返回當(dāng)前 URL 的協(xié)議。
URL 是:?http://example.com:1234/test.htm#part2:
location.protocol-------------http:
八、search設(shè)置或返回從問號 (?) 開始的 URL(查詢部分)。
URL 是:?http://www.w3school.com.cn/tiy/t.asp?f=hdom_loc_search
location.search-------------?f=hdom_loc_search