home ~ projects ~ socials

Get The Current URL For A Browser Page In JavaScript

Grab It

Use this to grab the URL for the current page:

const url = window.location.href

The reason to use this over document.URL is that the document version doesn't always update if an "#" anchor is added to the URL.

-- end of line --