HTML <button> atributo formtarget
Exemplo
Um formulário com dois botões de envio. O primeiro botão enviar envia os dados do formulário com destino padrão ("_self") e o segundo envia os dados do formulário para uma nova janela (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>
Definição e uso
O formtarget
atributo especifica onde exibir a resposta após o envio do formulário. Este atributo substitui o atributo do formulário target
.
O formtarget
atributo é usado apenas para botões com
type="submit"
.
Suporte ao navegador
Os números na tabela especificam a primeira versão do navegador que suporta totalmente o atributo.
Attribute | |||||
---|---|---|---|---|---|
formtarget | 9.0 | 10.0 | 4.0 | 5.1 | 10.6 |
Sintaxe
<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 |
❮ Tag HTML <button>