Web APIs
Window.location
Exposes the active document URL through Location. Reading it is not navigation; assign and replace have navigation effects.
Formal Syntax & Structure
javascript syntaxjavascript
window.location.hrefReturn Value
string
Current document URL when href is read.
Working Example
Example Snippetjavascript
(async () => {const before=location.href;const u=new URL("https://example.test/a");u.pathname="/b";console.log(location.href===before,u.pathname);})()