title: Figuring out Host's Top Domain with Javascript
body: <p>Is there a way to figure out what the top domain for the hostname of the current page is? The problem I have is that the script could be on .com domain, or in an international domain like .co.uk</p>
  
  <p>So for:
  jobs.telegraph.co.uk  - top domain is:telegraph.co.uk
  jobs.nytimes.com - top domain is nytimes.com</p>
  
  <p>The problem is that location.hostname , and the document.domain give the entire domain.</p>
  
  <p>One route is to have a list of all TLDs (too much to carry around) and parse based on that. Another route was if 2 characters after last ".", than internationaltion - hence last two are the TLD, but that does not hold true for all international domains.</p>