JSFiddle - React, Tailwind, and code Playground
by Increazon
JavaScript
function getHost(url)
{
var a = document.createElement('a');
a.href = url;
var host = a.hostname;
var spl = host.split('www.');
if (spl.length == 2) return spl[1];
else return host;
}
alert(getHost('http://stackoverflow.com/questions/2300771/jquery-domain-get-url'));
alert(getHost('http://www.stackoverflow.com/questions/2300771/jquery-domain-get-url'));