Jangkar hostname Properti
Contoh
Kembalikan nama host tautan:
var x = document.getElementById("myAnchor").hostname;
Definisi dan Penggunaan
Properti hostname menyetel atau mengembalikan bagian hostname dari nilai atribut href.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
hostname | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti nama host:
anchorObject.hostname
Setel properti nama host:
anchorObject.hostname = hostname
Nilai properti
Value | Description |
---|---|
hostname | Specifies the hostname of a URL |
Detail Teknis
Nilai Kembali: | Sebuah String, mewakili nama domain (atau alamat IP) dari URL |
---|
Lebih Banyak Contoh
Contoh
Ubah nama host tautan:
document.getElementById("myAnchor").hostname = "www.somenewexamplepage.com";
Contoh
Contoh lain tentang cara mengubah nama host tautan:
document.getElementById("myAnchor").hostname = "www.w3schools.com";
Halaman Terkait
Referensi JavaScript: location.hostname Property
Objek Jangkar