How to get the Domain Name from the URL

dhirenkaunar-15094
Posted by dhirenkaunar-15094 under JavaScript category on | Points: 40 | Views : 1219
function GetDoaminName()
//document.location.href this will be returning url of the current page
var domainName = fnGetDomain(document.location.href);
}

//Function is returning Domain Name.
function fnGetDomain(url) {
return (url.match(/:\/\/(.[^/]+)/)[1]);
}

Comments or Responses

Login to post response