Jangkar href Properti
Contoh
Ubah tujuan (URL) tautan:
document.getElementById("myAnchor").href = "http://www.cnn.com/";
Definisi dan Penggunaan
Properti href menyetel atau mengembalikan nilai atribut href dari sebuah tautan.
Atribut href menentukan tujuan tautan.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
href | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti href:
anchorObject.href
Setel properti href:
anchorObject.href = URL
Nilai properti
Value | Description |
---|---|
URL |
Specifies the URL of the link. Possible values:
|
Detail Teknis
Nilai Kembali: | Sebuah String, mewakili URL link. Mengembalikan seluruh URL, termasuk protokol (seperti http://) |
---|
Lebih Banyak Contoh
Contoh
Dapatkan URL tautan:
var x = document.getElementById("myAnchor").href;
Contoh
Contoh lain tentang cara mendapatkan URL tautan (URL relatif):
var x =
document.getElementById("myAnchor").href;
Halaman Terkait
Referensi HTML: HTML <a> href atribut
Objek Jangkar