用JS得到當前頁面詳細URL地址

設置或獲取對象指定的文件名或路徑。
<script>
alert(window.location.pathname)
</script>spa

設置或獲取整個 URL 爲字符串。
<script>orm

alert(window.location.href);
</script>
設置或獲取與 URL 關聯的端口號碼。
<script>
alert(window.location.port)
</script>對象

設置或獲取 URL 的協議部分。
<script>
alert(window.location.protocol)
</script>ip

設置或獲取 href 屬性中在井號「#」後面的分段。
<script>
alert(window.location.hash)
</script>字符串

設置或獲取 location 或 URL 的 hostname 和 port 號碼。
<script>
alert(window.location.host)
</script>hash

設置或獲取 href 屬性中跟在問號後面的部分。
<script>
alert(window.location.search)
</script>it

相關文章
相關標籤/搜索