学习如何使用 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 对象