Skip to content

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
See also  Deep Cloning Objects In JavaScript

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.