I am trying to extract the domain name from a url using javascript but having some problems.
This is what I have:
var publisherName = document.domain;
if(publisherName.indexOf('www')){
publisherName = document.domain.substr(3,document.domain.length);
}
But it is not working and I am not sure how to rid of the extension…ie…com,co.uk,net etc.
Basically, this is what I want: Whether the location being sub domain or not it need to get from somthing similar to - “http://www.sub.domain.com/dir1/dir2/page.html” to just “domain”.
Any help appreciated.