參考鏈接: http://blog.csdn.net/cui_angel/article/details/7957274
(1)window.location.pathname
設置或獲取對象指定的文件名或路徑。
(2)window.location.href
設置或獲取整個 URL 為字符串。
window.location.port
設置或獲取與 URL 關聯的端口號碼。
(3)window.location.hash
設置或獲取 href 屬性中在井號“#”后面的分段。
(4)window.location.search
設置或獲取 href 屬性中跟在問號后面的部分
(5)window.location.protocol
設置或獲取 URL 的協議部分。
【舉例】
http://www.x2y2.com:80/fisker/post/0703/window.location.html?ver=1.0&id=6#imhere
1, window.location.href 整個URl字符串(在瀏覽器中就是完整的地址欄) 本例返回值: http://www.x2y2.com:80/fisker/post/0703/window.location.html?ver=1.0&id=6#imhere 2,window.location.protocol URL 的協議部分 本例返回值:http: 3,window.location.host URL 的主機部分 本例返回值:www.x2y2.com 4,window.location.port URL 的端口部分 如果采用默認的80端口(update:即使添加了:80),那么返回值並不是默認的80而是空字符 本例返回值:"" 5,window.location.pathname URL 的路徑部分(就是文件地址) 本例返回值:/fisker/post/0703/window.location.html 6,window.location.search 查詢(參數)部分 除了給動態語言賦值以外,我們同樣可以給靜態頁面,並使用javascript來獲得相信應的參數值 本例返回值:?ver=1.0&id=6 7,window.location.hash 錨點 本例返回值:#imhere