How to get Current URL in JavaScript
You can use the JavaScript window.location.href
property to get the current URL in the browser. The result includes host name, query string, fragment identifier, etc.
The following example will display the current url of the page by calling the method currentURL().
const currentURL = () => window.location.href; currentURL(); //https://poopcode.com/get-current-url-in-javascript