why need jQuery , current url will be get by pure JavaScript very well. -
shabi
Jan 16 '17 00:09
var cuurent_url_1=document.location;
var cuurent_url_2=window.location;
alert(cuurent_url_1);
alert(cuurent_url_2);
console.log(window.location);
Location {hash: "#r&#removehash", search: "?d=", pathname: "/test/test3.php", port: "", hostname: "localhost"…}
var url_1=document.location.href;
var url_2=document.location.toString();
var url_3 = window.location.toString();
var url_4 = window.location.href();
var url_without_hash=document.location.href.replace(document.location.hash,"");
var url_without_hash=window.location.href.replace(window.location.hash,"");
var url= window.location.origin +window.location.pathname;
var url=document.location.origin +document.location.pathname;
var url=window.location.origin +window.location.pathname+window.location.search;
var url=document.location.origin +document.location.pathname+document.location.search;
console.log("output :: for current url -- "+window.location.origin +window.location.pathname );
// output :: for current url -- http://arrayoverflow.com/question/how-to-get-current-url-in-javascript/230
console.log("output :: for current url -- "+document.location.origin +document.location.pathname );
// output :: for current url -- http://arrayoverflow.com/question/how-to-get-current-url-in-javascript/230
console.log("output :: for current url -- "+document.location.origin +document.location.pathname +document.location.search);
// output :: for current url -- http://arrayoverflow.com/question/how-to-get-current-url-in-javascript/230
//believing that you embed url.js
console.log(url("hostname")+url("path"));
var url = $("*").context.baseURI;// give absolute url
var spliturl=url.split("#");// try to remove hash
console.log(spliturl[0]);
console.log(document.documentURI);//http://arrayoverflow.com/question/how-to-get-current-url-in-javascript/230