Skip to content

Instantly share code, notes, and snippets.

@tahirm
Last active August 1, 2021 13:34
Show Gist options
  • Save tahirm/9737947 to your computer and use it in GitHub Desktop.
Save tahirm/9737947 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 : '');
@Deuteu
Copy link

Deuteu commented Dec 19, 2017

What about : window.location.origin ?

@acanimal
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment