Tautkan href Properti
Contoh
Kembalikan URL dokumen tertaut:
var x = document.getElementById("myLink").href;
Definisi dan Penggunaan
Properti href menyetel atau mengembalikan URL dokumen tertaut.
Dukungan Peramban
Property | |||||
---|---|---|---|---|---|
href | Yes | Yes | Yes | Yes | Yes |
Sintaksis
Kembalikan properti href:
linkObject.href
Setel properti href:
linkObject.href = URL
Nilai properti
Value | Description |
---|---|
URL |
Specifies the URL of the linked resource/document Possible values:
|
Detail Teknis
Nilai Kembali: | Sebuah String, mewakili URL dari dokumen yang ditautkan. Mengembalikan seluruh URL, termasuk protokol (seperti http://) |
---|
Lebih Banyak Contoh
Contoh
Ubah lembar gaya:
document.getElementById("myLink").href = "style2.css";
Halaman Terkait
Referensi HTML: HTML <link> atribut href
Objek Tautan