Latest web development tutorials

Atrybut href HTML DOM link

Link referencyjny obiektu Link Objects

Definicja i Wykorzystanie

atrybut href jest do odczytu i zapisu zestawy strun lub zwraca pełny adres URL dokumentu aktualnie wyświetlanego.

gramatyka

Ustaw atrybut href:

linkObject.href="URL"

Powrót href atrybut:

linkObject.href


Pomoc Browser

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Wszystkie główne przeglądarki obsługują atrybut href


Przykłady

Przykłady

Kliknij na przycisk, aby przełączyć arkusze stylów:

<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> Ten poradnik (w3big.com) </ title>
<Link id = "style1" rel = "stylesheet" type = "text / css" href = "style1.css">
<Script>
Funkcja displayResult () {
document.getElementById ( "style1") href = "style2.css" .;
}
</ Script>
</ Head>
<Body>

<H1> My Home Page </ h1>
<Type = "button" button onclick = "displayResult ()">, aby przełączyć arkusze stylów </ button>

</ Body>
</ Html>

Spróbuj »


Link referencyjny obiektu Link Objects