Ancorare la proprietà di destinazione
Esempio
Cambia la destinazione di un link in "_blank" (il link verrà aperto in una nuova finestra):
document.getElementById("myAnchor").target = "_blank";
Definizione e utilizzo
La proprietà target imposta o restituisce il valore dell'attributo target di un collegamento.
L'attributo target specifica dove aprire il documento collegato.
Supporto browser
Property | |||||
---|---|---|---|---|---|
target | Yes | Yes | Yes | Yes | Yes |
Sintassi
Restituisce la proprietà di destinazione:
anchorObject.target
Imposta la proprietà di destinazione:
anchorObject.target = "_blank|_self|_parent|_top|framename"
Valori di proprietà
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 |
Dettagli tecnici
Valore di ritorno: | Una stringa, che rappresenta dove aprire il documento collegato |
---|
Altri esempi
Esempio
Restituisce il valore dell'attributo target di un collegamento:
var x =
document.getElementById("myAnchor").target;
Pagine correlate
Riferimento HTML: attributo di destinazione HTML <a>
❮ Ancora oggetto