Link hreflangPropiedad
Objeto Link
Definición y uso
La propiedad hreflang especifica el idioma del texto en el documento vinculado.
Sintaxis
Establecer la propiedad hreflang:
linkObject.hreflang="language-code"
Devolver la propiedad hreflang:
linkObject.hreflang
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten la propiedad hreflang.
Ejemplo
Ejemplo
Mostrar el idioma del documento vinculado:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<link id="link1" href="domoarigato.htm.html" hreflang="ja">
<script>
function displayResult(){
var x=document.getElementById("link1").hreflang;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">Mostrar el idioma del documento del elemento de enlace</button>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<link id="link1" href="domoarigato.htm.html" hreflang="ja">
<script>
function displayResult(){
var x=document.getElementById("link1").hreflang;
alert(x);
}
</script>
</head>
<body>
<button type="button" onclick="displayResult()">Mostrar el idioma del documento del elemento de enlace</button>
</body>
</html>
Pruébalo »
Objeto Link Otras extensiones