Skip to content

How to get current URL in javascript.

Published: at 12:40 PM

For getting the current url in javascript, we can use window.location.href. it will return the current URL of webpage. More about window.location

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the Document</title>
  </head>
  <body>
    <p id="href"></p>
    <script>
      document.getElementById("href").innerHTML ="The full URL of this page is:<br>" + window.location.href;
    </script>
  </body>
</html>