學習如何使用 JavaScript 獲取當前 URL。
使用 window.location.href 獲取當前 URL 地址:
window.location.href
document.getElementById("demo").innerHTML = "The full URL of this page is:<br>" + window.location.href;
親自試一試
參考手冊:JavaScript window.location 對象