javascript get url
snippet in javascript

jquery get current url

user8636

var currentURL = $(location).attr('href'); //jQuery solution
var currentURL = window.location.href; // raw javascript

javascript get url

user6071

var currentUrl = window.location.href;

get actual url in variable

user3206

var currentLocation = window.location;

javascript get base url

user8424

console.log(window.location.origin);

get url javascript

user5099


 document.getElementById("demo").innerHTML =
"Page location is " + window.location.href;

 

javascript get domain

user9744

window.location.hostname