Odkaz href Property
Příklad
Vraťte adresu URL odkazovaného dokumentu:
var x = document.getElementById("myLink").href;
Definice a použití
Vlastnost href nastavuje nebo vrací adresu URL propojeného dokumentu.
Podpora prohlížeče
Property | |||||
---|---|---|---|---|---|
href | Yes | Yes | Yes | Yes | Yes |
Syntax
Vraťte vlastnost href:
linkObject.href
Nastavte vlastnost href:
linkObject.href = URL
Hodnoty vlastností
Value | Description |
---|---|
URL |
Specifies the URL of the linked resource/document Possible values:
|
Technické údaje
Návratová hodnota: | Řetězec představující adresu URL odkazovaného dokumentu. Vrátí celou adresu URL včetně protokolu (např. http://) |
---|
Další příklady
Příklad
Změnit šablonu stylů:
document.getElementById("myLink").href = "style2.css";
Související stránky
HTML reference: HTML <link> href atribut
❮ Objekt odkazu