Skip to content

Instantly share code, notes, and snippets.

@englishextra
Forked from tahirm/getDomainName.js
Created September 6, 2016 17:42
Show Gist options
  • Save englishextra/e40ef2cae0c0f377783191b41f5af5ba to your computer and use it in GitHub Desktop.
Save englishextra/e40ef2cae0c0f377783191b41f5af5ba 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