As the complement of getting the domain name out of a URL and get domain name from URL using javascript, here is another way to get domain name using javascript.
If you are running a script in a website you can find out the domain name of the website by using document.domain property.
var mydomain=document.domain;