Attributo HTML <pulsante> formtarget

❮ Tag HTML <pulsante>

Esempio

Un modulo con due pulsanti di invio. Il primo pulsante di invio invia i dati del modulo con la destinazione predefinita ("_self") e il secondo invia i dati del modulo a una nuova finestra (target="_blank"):

<form action="/action_page.php" method="get">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name:</label>
  <input type="text" id="lname" name="lname"><br><br>
  <button type="submit" >Submit</button>
  <button type="submit" formtarget="_blank">Submit to a new window</button>
</form>

Definizione e utilizzo

L' formtargetattributo specifica dove visualizzare la risposta dopo aver inviato il modulo. Questo attributo sovrascrive l'attributo del modulo target.

L' formtargetattributo viene utilizzato solo per i pulsanti con type="submit".


Supporto del browser

I numeri nella tabella specificano la prima versione del browser che supporta completamente l'attributo.

Attribute
formtarget 9.0 10.0 4.0 5.1 10.6

Sintassi

<button type="submit" formtarget="_blank|_self|_parent|_top|framename">

Valori di attributo

Value Description
_blank Loads the response in a new window/tab
_self Loads the response in the same frame (this is default)
_parent Loads the response in the parent frame
_top Loads the response in the full body of the window
framename Loads the response in a named iframe

❮ Tag HTML <pulsante>