How TO - Get Current URL With JavaScript
Learn how to get the current URL with JavaScript.
Current URL
Use window.locaction.href
to get the current URL address:
Example
document.getElementById("demo").innerHTML =
"The full URL of this page
is:<br>" + window.location.href;
Try it Yourself »
Read more about the window.location
object in our JavaScript Window Location Tutorial.