Propiedad de destino de anclaje
Ejemplo
Cambie el destino de un enlace a "_blank" (el enlace se abrirá en una nueva ventana):
document.getElementById("myAnchor").target = "_blank";
Definición y uso
La propiedad de destino establece o devuelve el valor del atributo de destino de un vínculo.
El atributo de destino especifica dónde abrir el documento vinculado.
Compatibilidad con navegador
Property | |||||
---|---|---|---|---|---|
target | Yes | Yes | Yes | Yes | Yes |
Sintaxis
Devuelve la propiedad de destino:
anchorObject.target
Establezca la propiedad de destino:
anchorObject.target = "_blank|_self|_parent|_top|framename"
Valores de propiedad
Value | Description |
---|---|
_blank | Opens the linked document in a new window |
_self | Opens the linked document in the same frame as it was clicked (this is default) |
_parent | Opens the linked document in the parent frameset |
_top | Opens the linked document in the full body of the window |
framename | Opens the linked document in a named frame |
Detalles técnicos
Valor de retorno: | Una cadena, que representa dónde abrir el documento vinculado |
---|
Más ejemplos
Ejemplo
Devuelve el valor del atributo de destino de un enlace:
var x =
document.getElementById("myAnchor").target;
páginas relacionadas
Referencia HTML: atributo de destino HTML <a>
❮ Objeto de anclaje