get site url javascript
snippet in javascript

javascript get current url

user7377

var currentUrl = window.location.href;

get site url javascript

user6754

document.URL
> "http://example.com/page1.html"

document.location.href
> "http://example.com/page1.html"

document.location.pathname
> "/page1.html"

document.location.origin
> "http://example.com"

get actual url in variable

user2388

var currentLocation = window.location;