How to get current url in react

    how to get website url in javascript
    how to get base url in javascript
    how to get page url in javascript
    how to get site url in javascript
  • How to get website url in javascript
  • Get current url nextjs

  • Get current url nextjs
  • Javascript url example
  • Javascript get request
  • Javascript get url parameter
  • Get current url angular
  • Javascript get request...

    How to Get the Current URL using JavaScript?

    H

    1. Using Document.URL Property

    The DOM URL property in HTML is used to return a string that contains the complete URL of the current document.

    The string also includes the HTTP protocol such as ( http://).

    Syntax

    document.URL

    Return Value: It returns a string value that represents the full URL of the document. 

    Output

    http://127.0.0.1:5500/index.html

    2.

    Using window.location.href Property

    The window.location.href property of the HTML DOM Window object returns a string containing the URL of the current page. This property is part of the Location object, which contains information about the current location of the document.

    Syntax

    window.location.href

    Output:

    http://127.0.0.1:5500/index.html

    Note: Use the HTML file to copy paste and run the given code and you can see the output in the console, it will print the URL.



      how to get base url in javascript laravel
      how to get website link in javascript