HTML DOM Input Submit formTarget property

The HTML DOM Input Submit formTarget property is used for setting or returning the formTarget attribute value of a submit button. The HTML DOM Input Submit formTarget property is where the response from server should be displayed after the form data being submitted. The formTarget property overrides the target property of the form element. It introduced in HTML5 for input element with type submit.


Following is the syntax for −

Setting the formTarget property −

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

Here, _blank will open the response in new window;_self will open the response in the same window; parent will open in the parent frame ; _top will open in full window body and framename will open it in a specified named frame.


Let us look at an example for the Submit formTarget property −

Live Demo

<!DOCTYPE html>
<h1>Submit formTarget property</h1>
<form id="FORM_1" action="/Sample.php" style="border:solid 2px green;padding:2px">
UserName: <input type="text" id="USR"> <br>
Location: <input type="text" id="Loc"> <br><br>
<input type="submit" id="SUBMIT1" formtarget=_self>
<p>View the form response in the new window instead of same window by clicking the below button</p>
<button onclick="changeTarget()">CHANGE</button>
<p id="Sample"></p>
   function changeTarget() {
      document.getElementById("Sample").innerHTML = "The response will now open in the new window";


This will produce the following output −

On clicking the CHANGE button −