設定或獲取物件指定的檔名或路徑。
window.location.pathname
例:http://localhost:8086/topic/index?topicid=361
alert(window.location.pathname); 則輸出:/topic/index
設定或獲取整個 url 為字串。
window.location.href
例:http://localhost:8086/topic/index?topicid=361
alert(window.location.href); 則輸出:http://localhost:8086/topic/index?topicid=361
設定或獲取與 url 關聯的埠號碼。
window.location.port
例:http://localhost:8086/topic/index?topicid=361
alert(window.location.port); 則輸出:8086
設定或獲取 url 的協議部分。
window.location.protocol
例:http://localhost:8086/topic/index?topicid=361
alert(window.location.protocol); 則輸出:http:
設定或獲取 href 屬性中在井號「#」後面的分段。
window.location.hash
設定或獲取 location 或 url 的 hostname 和 port 號碼。
window.location.host
例:http://localhost:8086/topic/index?topicid=361
alert(window.location.host); 則輸出:http:localhost:8086
設定或獲取 href 屬性中跟在問號後面的部分。
window.location.search
例:http://localhost:8086/topic/index?topicid=361
alert(window.location.search); 則輸出:?topicid=361
window.location
屬性 描述
hash 設定或獲取 href 屬性中在井號「#」後面的分段。
host 設定或獲取 location 或 url 的 hostname 和 port 號碼。
hostname 設定或獲取 location 或 url 的主機名稱部分。
href 設定或獲取整個 url 為字串。
pathname 設定或獲取物件指定的檔名或路徑。
port 設定或獲取與 url 關聯的埠號碼。
protocol 設定或獲取 url 的協議部分。
search 設定或獲取 href 屬性中跟在問號後面的部分。
JS獲取當前頁面頁面URL資訊
url即 統一資源定位符 uniform resource locator,url 完整的url由這幾個部分構成 scheme host port path?query fragment scheme 通訊協議 常用的http,ftp,maito等 設定或獲取url從頭到埠號部分。url windo...
js獲取當前頁面的url資訊
設定或獲取物件指定的檔名或路徑。alert window.location.pathname 設定或獲取整個 url 為字串。alert window.location.href 設定或獲取與 url 關聯的埠號碼。alert window.location.port 設定或獲取 url 的協議部分...
JS獲取當前頁面的URL等資訊
設定或獲取物件指定的檔名或路徑。alert window.location.pathname 設定或獲取整個 url 為字串。alert window.location.href 設定或獲取與 url 關聯的埠號碼。alert window.location.port 設定或獲取 url 的協議部分...