HTML DOM Tautan atribut href
Definisi dan Penggunaan
Atribut href adalah dibaca dan ditulis set string atau mengembalikan URL lengkap dari dokumen yang sedang ditampilkan.
tatabahasa
Mengatur atribut href:
linkObject.href="URL"
Kembali atribut href:
linkObject.href
Dukungan Browser
Semua browser utama mendukung atribut href
contoh
contoh
Klik tombol untuk beralih style sheet:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Link id = "style1" rel = "stylesheet" type = "text / css" href = "style1.css">
<Script>
Fungsi displayResult () {
document.getElementById ( "style1") href = "style2.css" .;
}
</ Script>
</ Kepala>
<Body>
<H1> My Halaman </ h1>
<Tombol type = "button" onclick = "displayResult ()"> untuk beralih style sheet </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Tutorial ini (w3big.com) </ title>
<Link id = "style1" rel = "stylesheet" type = "text / css" href = "style1.css">
<Script>
Fungsi displayResult () {
document.getElementById ( "style1") href = "style2.css" .;
}
</ Script>
</ Kepala>
<Body>
<H1> My Halaman </ h1>
<Tombol type = "button" onclick = "displayResult ()"> untuk beralih style sheet </ button>
</ Body>
</ Html>
Coba »
Link Objects