Javascript: Get host info

var url = new URL("",location); console.log(; // ip address or hostname:port number console.log(url.protocol); // protocol console.log(url.hostname); // ip address or hostname console.log(url.port); // port number console.log(url.origin); // protocol://ip address or hostname:port number console.log(url.pathname); // /current path/
Information about host url

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.