Find top level domain in current address (JavaScript)


/ Published in: JavaScript
Save to your folder(s)

Find top level domain in current address (JavaScript)


Copy this code and paste it in your HTML
  1. el = document.createElement('DIV');
  2. el.id="info";
  3. document.body.appendChild(el);
  4.  
  5.  
  6. var re=/\.([^\.]+?)$/;
  7.  
  8. domain = re.exec(location.hostname);
  9.  
  10. el.innerHTML= domain[1];

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.