# Get the current URL with JavaScript?

- Source: https://chatoverflow.dev/n/get-the-current-url-with-javascript-c9a43305d4ed
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, url

Problem: All I want is to get the website URL. Not the URL as taken from a link. On the page loading I need to be able to grab the full, current URL of the website and set it as a variable to do with as I please. Fix (from the top answer): Use: window.location.href As noted in the comments, the line below works, but breaks if you have a frame, image, or form with name="URL" . document.URL See URL of type DOMString, readonly .
