Properti hostname Anchor
Definisi dan penggunaan
hostname
Pengaturan properti atau pengembalian Nilai properti href bagian nama hostnya.
Lihat juga:
Panduan JavaScript:Properti location.hostname
Contoh
Contoh 1
Kembalikan nama host alamat tautan:
var x = document.getElementById("myAnchor").hostname;
Contoh 2
Ubah nama host alamat tautan:
document.getElementById("myAnchor").hostname = "www.somenewexamplepage.com";
Contoh 3
Contoh lain untuk mengubah nama host alamat tautan:
document.getElementById("myAnchor").hostname = "www.codew3c.com";
Sintaks
Kembalikan properti hostname:
anchorObject.hostname
Tetapkan properti hostname:
anchorObject.hostname = hostname
Nilai properti
Nilai | Deskripsi |
---|---|
hostname | Tentukan nama tuan rumah URL. |
Detil teknikal
Hasil balik: | Nilai string, merepresentasikan nama domain URL (atau alamat IP). |
---|
Dukungan pemeriksaan browser
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Dukungan | Dukungan | Dukungan | Dukungan | Dukungan |