HTML | DOM Input Submit formTarget Property

The Input Submit formTarget Property in HTML DOM is used to set or return the value of the target 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 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.

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :
Before Clicking the Button:

After Clicking the Button:

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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

Check out this Author's contributed articles.

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.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.