Open In App

HTML DOM Input Submit formTarget Property

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: 



submitObject.formTarget
submitObject.formTarget = "_blank|_self|_parent|_top|framename"

Property Values:

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. 




<!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. 




<!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:


Article Tags :