I have domain name for eq.
1) http://www.abc.com/search 2) http://go.abc.com/work
I get only domain name from the above URL
Output
var hostname = window.location.origin
Will not work for IE. For IE support as well I would something like this:
var hostName = window.location.hostname; var protocol = window.locatrion.protocol; var finalUrl = protocol + '//' + hostname;