1、設置或獲取對象指定的文件名或路徑。
window.location.pathname
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.pathname); 則輸出:/topic/index
2、設置或獲取整個 URL 為字符串。
window.location.href
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.href); 則輸出:http://localhost:8086/topic/index?topicId=361
3、設置或獲取與 URL 關聯的端口號碼。
window.location.port
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.port); 則輸出:8086
4、設置或獲取 URL 的協議部分。
window.location.protocol
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.protocol); 則輸出:http:
5、設置或獲取 href 屬性中在井號“#”后面的分段。
window.location.hash
6、設置或獲取 location 或 URL 的 hostname 和 port 號碼。
window.location.host
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.host); 則輸出:http:localhost:8086
7、設置或獲取 href 屬性中跟在問號后面的部分。
window.location.search
例:http://localhost:8086/topic/index?topicId=361
alert(window.location.search); 則輸出:?topicId=361
---------------------
作者:大洋PHP
來源:CSDN
原文:https://blog.csdn.net/eddy23513/article/details/81703215
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!