JavaScript Reference/Javascript Properties/hostname

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

"hostname" Example

    
<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>



"hostname" is applied to

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



"hostname" Syntax and Note

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