Sometimes, we want to make a form open a new window showing the result after submitting a POST request with JavaScript.
In this article, we’ll look at how to make a form open a new window showing the result after submitting a POST request with JavaScript.
How to make a form open a new window showing the result after submitting a POST request with JavaScript?
To make a form open a new window showing the result after submitting a POST request with JavaScript, we set the target
attribute of the form to _blank
.
To do this, we write
form.setAttribute("target", "_blank");
to call form.setAttribute
with 'target'
and '_blank'
to make the form
element open a new window after the form is submitted.
Conclusion
To make a form open a new window showing the result after submitting a POST request with JavaScript, we set the target
attribute of the form to _blank
.