HTML | DOM Button formTarget Property
The Button formTarget property in HTML DOM is used to set or return the value of the formTarget attribute of a button. After submission of the form the formTarget attribute is called. The form data is to be sent to the server after submission of the form.
Syntax:
- It is used to return the formTarget property.
buttonObject.formTarget
- It is used to set the formTarget property.
buttonObject.formTarget = "_blank | _parent | _self | _top | framename"
Property Values:
- _blank: It is used to load the response in a new window/tab.
- _parent: It is used to load the response in the parent frame.
- _self:It is the default value and used to load the response in the same frame.
- _top: It is used to load the response in the full body of the window.
- framename: It is used to load the response in a named iframe.
Return Value: It returns a string value which represent the place where the response has to be submitted.
Example: This example describes how to set and get the value of formTarget property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Button formTarget Property </title> </head> <body> <h1>GeeksforGeeks</h1> <h2>DOM Button formTarget Property</h2> <form action="/gfg.php" method="post" id="users"> <label for="username">Username:</label> <input type="text" name="username" id="Username"> <br><br> <label for="password">Password :</label> <input type="password" name="password"> <button id="btn" type="submit" formtarget="_blank"> Load Changed formAction value</button> </form> <br> <button onclick = "myGeeks()"> Submit </button> <p id = "GFG"></p> <!-- script to set and get the value of formTarget attribute --> <script> function myGeeks() { var x = document.getElementById("btn").formTarget ; var y = document.getElementById("btn").formTarget = "_self"; document.getElementById("GFG").innerHTML = "formTarget changed to " + y + "<br> from "+ x ; } </script> </body> </html> |
Output:
Before clicking on button:

After clicking on button:

Supported Browsers:
- Internet Explorer 10.0
- Google Chrome
- Mozilla Firefox
- Opera
- Safari
Recommended Posts:
- HTML | <button> formtarget Attribute
- HTML | DOM Input Submit formTarget Property
- HTML | DOM Input Image formTarget Property
- HTML | DOM Button name Property
- HTML | DOM Button value Property
- HTML | DOM Button disabled Property
- HTML | DOM Button autofocus Property
- HTML | DOM Button type Property
- HTML | DOM Button formEnctype Property
- HTML | DOM Button formNoValidate Property
- HTML | DOM Input Button name Property
- HTML | DOM Button formMethod Property
- HTML | DOM Button formAction Property
- HTML | DOM Button form Property
- HTML | DOM Input Button value Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



