get domain name javascript

JavaScript
var currentUrl = window.location.href;window.location.hostname
Source

Also in JavaScript: