JavaScript Reference/Javascript Properties/hostname

Материал из Web эксперт
Перейти к: навигация, поиск

"hostname" Example

   <source lang="javascript">
   

<html> <body> <script language="JavaScript">

   function function1() {
       alert(document.getElementById("myA").host);
   }

</script> <a id="myA" href="http://www.wbex.ru" target="_blank">wbex.ru Home Page</a> <button onclick="function1();">Host Value</button> <button onclick="alert(document.all.myA.hostname);">Host Name</button> </body> </html>


     </source>
   
  


"hostname" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <area> | | |location | +----------------+--------------------------------------------------------------+

     </source>
   
  


"hostname" Syntax and Note

   <source lang="javascript">

Note: Read and write property. Specifies the URL domain name.

Syntax:

document.getElementById("elementID").hostname = value document.all.elementID.hostname = value // IE only location.hostname = value


     </source>