Atributo HTML <button> formtarget

❮ Etiqueta HTML <botón>

Ejemplo

Un formulario con dos botones de envío. El primer botón de envío envía los datos del formulario con el destino predeterminado ("_self"), y el segundo envía los datos del formulario a una nueva ventana (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>

Definición y uso

El formtargetatributo especifica dónde mostrar la respuesta después de enviar el formulario. Este atributo anula el atributo del formulario target.

El formtargetatributo solo se usa para botones con type="submit".


Compatibilidad con navegador

Los números de la tabla especifican la primera versión del navegador que es totalmente compatible con el atributo.

Attribute
formtarget 9.0 10.0 4.0 5.1 10.6

Sintaxis

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

Valores de atributo

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

❮ Etiqueta HTML <botón>