atributo href HTML DOM Enlace
Definición y Uso
atributo href es una de lectura y escritura conjuntos de cuerda o devuelve la URL completa del documento que se muestra actualmente.
gramática
Establecer el atributo href:
linkObject.href="URL"
Volver atributo href:
linkObject.href
Soporte para el navegador
Todos los principales navegadores soportan atributo href
Ejemplos
Ejemplos
Haga clic en un botón para cambiar las hojas de estilo:
<! DOCTYPE html>
<Html>
<Head>
<Charset Meta = "UTF-8">
<Title> Este tutorial (w3big.com) </ title>
<Enlace de id = rel = tipo "style1" "estilo" = "text / css" href = "style1.css">
<Script>
displayResult función () {
document.getElementById ( "style1") href = "style2.css" .;
}
</ Script>
</ Head>
<Cuerpo>
<H1> Mi página de inicio </ h1>
<Botón type = "button" onclick = "displayResult ()"> para cambiar las hojas de estilo </ botón>
</ Body>
</ Html>
<Html>
<Head>
<Charset Meta = "UTF-8">
<Title> Este tutorial (w3big.com) </ title>
<Enlace de id = rel = tipo "style1" "estilo" = "text / css" href = "style1.css">
<Script>
displayResult función () {
document.getElementById ( "style1") href = "style2.css" .;
}
</ Script>
</ Head>
<Cuerpo>
<H1> Mi página de inicio </ h1>
<Botón type = "button" onclick = "displayResult ()"> para cambiar las hojas de estilo </ botón>
</ Body>
</ Html>
Trate »
Objetos de enlace