Skip to content

Instantly share code, notes, and snippets.

@Victa
Created June 11, 2011 11:20
Show Gist options
  • Save Victa/1020464 to your computer and use it in GitHub Desktop.
Save Victa/1020464 to your computer and use it in GitHub Desktop.
Parse url to get hostname
var a = document.createElement('a');
a.href = url;
// any property of window.location works here:
document.write('The hostname of ' + url + ' is ' + a.hostname);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment