Open In App

HTML DOM Input Submit formTarget Property

Improve
Improve
Like Article
Like
Save
Share
Report

The Input Submit formTarget Property in HTML DOM is used to set or return the value of the formtarget attribute of the submit field. The Target attribute is used to specify whether the submitted result will open in the current window, a new tab or on a new frame. 

Syntax: 

  • It is used to return the formTarget property.
submitObject.formTarget
  • It is used to set the formTarget property.
submitObject.formTarget = "_blank|_self|_parent|_top|framename"

Property Values:

  • _blank: It defines that the submitted result will open in a new window or in a new tab.
  • _self: It is the default value. It specifies that the submitted result will be open in the same window.
  • _parent: It specifies that the result will be open in a parent frameset.
  • _top: It specify that the result will open in a full body of the window.
  • framename: It opens the response in a named frame.

Return Value: It returns a string value that represents whether the submitted result will open in the current window, a new tab, or on a new frame. 

Example 1: This example illustrates how to return Input Submit formTarget property. 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Submit formTarget Property
    </title>
</head>
 
<body style="text-align:center;">
    <h1>
        GeeksForGeeks
    </h1>
    <h2>
        HTML DOM Input Submit formtarget Property
    </h2>
    <form action="#" method="get" target="_self">
        <input type="submit" id="Geeks"
               name="myGeeks" formTarget="_blank"
               value="Submit @ geeksforgeeks" >
    </form>
    <p>
        click on below button to return the Property
    </p>
    <button onclick="myGeeks()">
        Click Here!
    </button>
    <p id="GFG" style="font-size:25px;"></p>
 
    <!-- Script to return submit formTarget Property -->
    <script>
        function myGeeks() {
            let btn = document.getElementById("Geeks").formTarget;
            document.getElementById("GFG").innerHTML = btn;
        }
    </script>
</body>
 
</html>


Output: 

 

Example 2: This example illustrates how to set Input Submit formTarget Property. 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM Input Submit formTarget Property
    </title>
</head>
 
<body style="text-align:center;">
    <h1>
        GeeksForGeeks
    </h1>
    <h2>
        HTML DOM Input Submit formtarget Property
    </h2>
    <form action="#" method="get" target="_self">
        <input type="submit" id="Geeks"
               name="myGeeks" formTarget="_blank"
               value="Submit @ geeksforgeeks" >
    </form>
    <p>
        click on below button to set the Property
    </p>
    <button onclick="myGeeks()">
        Click Here!
    </button>
    <p id="GFG" style="font-size:23px;"></p>
 
    <!-- Script to set submit formTarget Property -->
    <script>
        function myGeeks() {
            let btn = document.getElementById("Geeks").formTarget
                = "_self";
 
            document.getElementById("GFG").innerHTML
                = "The value of the Formtarget attribute"
                + " was changed to " + btn;
        }
    </script>
</body>
 
</html>


Output: 

 

Supported Browsers: The browser supported by DOM input submit formTarget property are listed below:

  • Google Chrome 1 and above
  • Edge 12 and above
  • Firefox 1 and above
  • Opera
  • Safari 1 and above


Last Updated : 16 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads