Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | DOM Input Submit formTarget Property

  • Difficulty Level : Basic
  • Last Updated : 10 Nov, 2021

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:

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.
    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 specifies that the submitted result will be open in a 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 which 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"
            value = "Submit @ geeksforgeeks" formTarget="_blank">
    </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() { 
            var btn = document.getElementById("Geeks").formTarget;
            document.getElementById("GFG").innerHTML = btn; 
        
    </script
</body
  
</html>                                

Output :
Before Clicking the Button:

After Clicking the Button:

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"
        value = "Submit @ geeksforgeeks" formTarget="_blank">
    </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() { 
            var btn = document.getElementById("Geeks").formTarget
                    = "_self";
                      
            document.getElementById("GFG").innerHTML 
                    = "The value of the Formtarget attribute"
                      + " was changed to " + btn; 
        
    </script
</body
  
</html>                    

Output:
Before Clicking the Button:

After Clicking the Button:

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

  • Google Chrome
  • Internet Explorer 10.0
  • Firefox
  • Opera
  • Safari



My Personal Notes arrow_drop_up
Recommended Articles
Page :