Contoh
Kembali URL dari dokumen terkait:
var x = document.getElementById("myLink").href;
Hasil x akan:
http://www.w3ii.com/jsref/styles.css
Cobalah sendiri " Definisi dan Penggunaan
Properti href menetapkan atau mengembalikan URL dari dokumen terkait.
Dukungan Browser
Properti href didukung di semua browser utama.
Sintaksis
Kembali properti href:
linkObject .href
Mengatur properti href:
linkObject .href=URL
Nilai properti
Value | Description |
---|---|
URL |
Specifies the URL of the linked resource/document Possible values:
|
Rincian teknis
Kembali Nilai: | Sebuah String, mewakili URL dari dokumen terkait. Mengembalikan seluruh URL, termasuk protokol (seperti http: //) |
---|
Contoh lebih
Contoh
Mengubah style sheet:
document.getElementById("myLink").href = "style2.css";
Cobalah sendiri " Pages terkait
Referensi HTML: HTML <link> atribut href
