Skip to content

Instantly share code, notes, and snippets.

@illucent
Forked from tahirm/getDomainName.js
Created January 22, 2016 13:08
Show Gist options
  • Select an option

  • Save illucent/3b01ef05984d3511bf4c to your computer and use it in GitHub Desktop.

Select an option

Save illucent/3b01ef05984d3511bf4c to your computer and use it in GitHub Desktop.
Get complete domain name with protocol and port if available. #js #url From http://stackoverflow.com/questions/6941533/javascript-get-protocol-domain-and-port-from-url
var domain = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port : '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment