How TO - Get Current URL With JavaScript


Learn how to get the current URL with JavaScript.


Current URL

Use window.location.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.


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.