Mega Code Archive

 
Categories / JavaScript Tutorial / Location
 

Location hostname

The hostname property represents the hostname portion of the URL. <html>     <head>     <title> Using the hostname property of the Location object</title>     </head>     <body>     <script language="JavaScript">     <!--     function show(){          alert(document.location.hostname);     }     -->     </script>     <form name="form1">     Click the button to get the current location.hostname     <br>     http://www.rntsoft.com     <br>     <input type="button" name="gethost" value="Get hostname" onClick='show()'>     <br>     </form>     </body>     </html>