Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js get hostname from url

url = "http://www.example.com/path/to/somwhere";
urlParts = /^(?:w+://)?([^/]+)([^?]*)??(.*)$/.exec(url);
hostname = urlParts[1]; // www.example.com
path = urlParts[2]; // /path/to/somwhere
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #hostname #url
ADD COMMENT
Topic
Name
9+4 =