var parts = location.hostname.split('.');
var subdomain = parts.shift();
var upperleveldomain = parts.join('.');
To get only the second-level-domain, you might use
var parts = location.hostname.split('.');
var sndleveldomain = parts.slice(-2).join('.');
More Related Contents:
- Sorting array of object based on range of Numbers of String [closed]
- expected ‘;’ and instead saw ‘=’ [closed]
- How to read each element of an array in jQuery? [closed]
- How to wait until an element exists?
- jQuery load more data on scroll
- Can I call jQuery’s click() to follow an link if I haven’t bound an event handler to it with bind or click already?
- How to generate a simple popup using jQuery
- Why would multiple simultaneous AJAX calls to the same ASP.NET MVC action cause the browser to block?
- jQGrid, how to make a column editable in the add dialog but not during (inline) edits
- How to display JavaScript variables in a HTML page without document.write
- How to make a link open multiple pages when clicked
- How to detect if javascript files are loaded?
- How to remove text (without removing inner elements) from a parent element using jquery
- .append(), prepend(), .after() and .before()
- Ajax call Into MVC Controller- URL Issue
- JavaScript REST client Library [closed]
- Text blinking jQuery
- How can I give control back (briefly) to the browser during intensive JavaScript processing?
- Remove plus sign (+) in URL query string
- Mozilla firefox not working with window.onbeforeunload
- Why is my ‘load’ event/function not beeing executed after switching to jQuery 3?
- Why does multiple modal using twitter bootstrap got error too much recursion?
- How to wrap each word of an element in a span tag?
- Disable future dates after today in Jquery Ui Datepicker
- Iframe.readyState does not work in chrome
- Updating existing URL querystring values with jQuery
- Lock tab key with javascript?
- Bootstrap modal hide is not working
- How can I calculate the difference between two times that are in 24 hour format?
- Why do functional pseudos such as :not() and :has() allow quoted arguments?