Get the URL/Address of the Current Page in JavaScript
September 2025
The Window href
Use window.. to get the URL of the current page.
JavaScript
const pageUrl = window..;
document
.
. = pageUrl;
HTML
waiting
Output
waiting
Parts of the URL
A couple useful parts:
JavaScript
let urlForParts = ;
// overwriting so all the examples
// have something to show:
urlForParts = ;
const parts = ;
const outputList = document
.
parts.;
HTML
Output
end of line