Javascript examples for DOM HTML Element:Form
The target property sets or gets the target attribute in a form, which indicates where to display the response received after submitting the form.
Set the target property with the following Values
Value | Description |
---|---|
_blank | Opens in a new window |
_self | Opens in the same frame as it was clicked (default) |
_parent | Opens in the parent frameset |
_top | Opens in the full body of the window |
framename | Opens in a named frame |
A String, representing where to display the response that is received after submitting the form
The following code shows how to change where to display the response that is received after submitting a form:
<!DOCTYPE html> <html> <body> <form id="myForm" action="#"> First name: <input type="text" name="fname" value="Donald"><br> Last name: <input type="text" name="lname" value="Duck"><br> <input type="submit" value="Submit"> </form>// w w w . jav a2s . com <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myForm").target = "_blank"; document.getElementById("demo").innerHTML = "The value of the target attribute was changed."; } </script> </body> </html>