Extract Hostname Portion Of Url With JavascriptLearn Javascript / By nukeama Here is way to extract url from javascript <script> alert('document.location.href '+ document.location.href); alert('window.location.host ' + window.location.host); alert('window.location.hostname ' + window.location.hostname); alert('window.location.protocol ' + window.location.protocol); alert('window.location.port' + window.location.port); alert('window.location.pathname '+ window.location.pathname); alert('window.location.origin '+ window.location.origin); alert('window.location.search '+ window.location.search); </script> View Demo