Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | DOM Button formTarget Property

  • Last Updated : 30 Sep, 2019

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.


Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

  • It is used to return the formTarget property.
  • 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 DOM Button formTarget Property 
    <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"
        <label for="password">Password :</label
        <input type="password" name="password"
        <button id="btn" type="submit" formtarget="_blank">
            Load Changed formAction value</button>
    <button onclick = "myGeeks()"
    <p id = "GFG"></p
    <!-- script to set and get the value of formTarget attribute -->
    function myGeeks() { 
        var x = document.getElementById("btn").formTarget ;
                var y = document.getElementById("btn").formTarget = "_self";
            = "formTarget changed to " + y  + "<br> from "+ x ; 

Before clicking on button:

After clicking on button:

Supported Browsers:

  1. Internet Explorer 10.0
  2. Google Chrome
  3. Mozilla Firefox
  4. Opera
  5. Safari

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!