HTML | DOM Input Image formTarget Property

The HTML DOM Input Image formTarget Property is used to set or return the value of the formTarget of the Input Element having image 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:

  • To returns the formTarget Property.
    imageObject.formTarget
  • To sets the formTarget Property.
    imageObject.formTarget

Property Values: It accepts five parameters as mentioned and described below:

  • _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 Image formTarget property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML DOM Input Image formTarget Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
      GeeksforGeeks 
    </h1>
  
    <h2>
      DOM Input Image formTarget Property
    </h2>
    <button onclick="my_geek()">
        <input id="myImage" name="myGeeks" type="image" src=
               alt="Submit" formaction="#" a formtarget="_blank" 
               formenctype="text/plain" width="48" height="48">
    </button>
    <h2 id="Geek_h" style="color:green;"></h2>
    <script>
        function my_geek() {
  
            // Return formTarget, formEnctype and formAction. 
            var txt = document.getElementById(
                "myImage").formTarget;
            document.getElementById("Geek_h").innerHTML = txt;
        }
    </script>
</body>
  
</html>

chevron_right


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

Example 2: This Example illustrates how to set the Property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML DOM Input Image formTarget Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <h1 style="color:green;"
     GeeksforGeeks 
    </h1>
  
    <h4>
      DOM Input Image formTarget Property
    </h4>
    <button onclick="my_geek()">
        <input id="myImage" name="myGeeks" type="image" src=
               alt="Submit" formaction="#" a formtarget="_blank" 
               formenctype="text/plain" width="48" height="48">
    </button>
    <h2 id="Geek_h" style="color:green;"
  
        </h2>
    <script>
        function my_geek() {
  
            // Return formTarget, formEnctype and formAction. 
            var txt = document.getElementById(
                "myImage").formTarget = "_self";
            document.getElementById("Geek_h").innerHTML =
              "The formTarget as changed to " + txt;
        }
    </script>
</body>
  
</html>

chevron_right


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

Supported Browsers: The browsers supported by HTML DOM Input Image formTarget Property are listed below:

  • Google Chrome 9.0
  • Internet Explorer 10.0
  • Firefox 4.0
  • Opera 10.6
  • Safari 5.1


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.



Improved By : shubham_singh



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.