如何使用 JavaScript 獲取當前 URL

學習如何使用 JavaScript 獲取當前 URL。

當前 URL

使用 window.location.href 獲取當前 URL 地址:

實例

document.getElementById("demo").innerHTML =
"The full URL of this page is:<br>" + window.location.href;

親自試一試

相關頁面

參考手冊:JavaScript window.location 對象