URL के होस्टनाम भाग को निकालने के लिए, होस्टनाम विधि का उपयोग करें
उदाहरण
लाइव डेमो
<!DOCTYPE html>
<html>
<body>
<script>
var url = new URL("http://example.com/asdf/asdf/sadf.aspx?blah");
document.write(url.hostname);
</script>
</body>
</html>