如何使用JavaScript获取当前URL?
要使用JavaScript获取当前URL,请使用window.location.href属性-
示例
<!DOCTYPE html> <html> <body> <h3>Get current URL</h3> <p id="test"></p> <script> document.getElementById("test").innerHTML = "URL of the page: " + window.location.href; </script> </body> </html>