Submit an HTML Form to a New Tab or Window

Use the form target="_blank" attribute when the submitted response should open in a new browsing context. In most browsers this is a new tab, although the browser or user settings ultimately decide whether it appears as a tab or window.

<form action="test5.php" method="post" target="_blank">
  <label for="name">Name</label>
  <input type="text" id="name" name="name">
  <button type="submit">Submit in new tab</button>
</form>

The form data is sent to test5.php, while the current page remains open. This can be useful for reports, previews, generated graphs, or other results that users may want to inspect without leaving the form.

HTML form submitting its data to a new tab or window
Submitting form to new window and multiple submit buttons to post data to different target pages

Working Example Top ↑

This demo submits the value to the original test5.php processing page and asks the browser to show the response in a new tab or window.

Using target on the Form Top ↑

When every submission from a form should open separately, put target="_blank" on the <form> element.

<form action="test5.php" method="post" target="_blank">
  <input type="text" name="name" value="plus2net">
  <button type="submit">Open result</button>
</form>

Open Only One Submit Button in a New Tab Top ↑

If the form normally submits in the current tab but one submit button should open the response separately, use formtarget="_blank" on that button. This avoids changing the form with JavaScript.

<form action="test5.php" method="post">
  <button type="submit">Submit here</button>
  <button type="submit" formtarget="_blank">Open separately</button>
</form>

For multiple buttons that submit to different action pages, see submitting one form to different pages.

Using a Named Target Top ↑

A named target can reuse the same secondary browsing context for later submissions instead of requesting a new one each time.

<form action="test5.php" method="post" target="reportWindow">
  ...
</form>

This can be useful for repeated previews or reports. Do not rely on a specific window size or position; browsers control how browsing contexts are presented.

Do You Need JavaScript? Top ↑

Not for the basic case. The original page changed this.form.target inside an onclick handler. Native target or formtarget is simpler and keeps submission behavior in the form markup.

JavaScript is useful only when the destination or workflow genuinely depends on application logic that HTML attributes cannot express cleanly.

GET, POST and Security Top ↑

The target does not determine whether a form uses GET or POST. Choose the method according to what the request does:

  • GET: commonly appropriate for retrievable searches, filters, and other requests that can be represented in a URL.
  • POST: commonly appropriate for submissions that create or change server-side state or carry larger form bodies.
POST is not encryption. Sensitive information still requires HTTPS, and the processing page must validate submitted data on the server.

Accessibility and UX Top ↑

Opening a new tab or window changes the user's browsing context, so use it only when it provides a clear benefit. Button text should make the behavior understandable, such as “Open report in new tab.” Keep form controls properly labeled, and do not use a new tab merely to prevent users from leaving a page.

For routine form completion, submitting in the same tab is usually simpler. New browsing contexts are most useful when users need to compare or repeatedly generate results while keeping the original form available.

Common Mistakes Top ↑

Changing the target with onclick Top ↑

For standard cases, use target or formtarget. They are clearer and work without JavaScript.

Assuming _blank always means a new window Top ↑

_blank requests a new browsing context. The browser may present it as a tab or a window.

Using a new tab for every form Top ↑

Unexpected context changes can confuse users. Use the pattern only when keeping the original page open has a practical purpose.

Trusting submitted values Top ↑

The destination page must validate and process submitted values safely regardless of where the result opens.

Frequently Asked Questions Top ↑

Q1: How do I submit an HTML form to a new tab?

Add target="_blank" to the form when every submission should open separately.

Q2: Can only one submit button open the response in a new tab?

Yes. Put formtarget="_blank" on that submit button while leaving the form's normal target unchanged.

Q3: Do I need JavaScript to submit a form to a new tab?

No. The native target and formtarget attributes cover the common cases.

Q4: Does _blank always open a new browser window?

No. It opens a new browsing context, which the browser may display as a tab or a window.

Q5: Can I submit a POST form to a new tab?

Yes. The form can use method="post" together with target="_blank".

Q6: Is submitting with POST secure by itself?

No. POST does not encrypt the data. Use HTTPS for sensitive information and validate all submitted values on the server.

Submit form data to different pages Back to Previous Page
HTML Form



plus2net.com







Mohamed Osama

25-11-2015

Thanks it's works fine with me :) to open new tab after submit
amlan roy

22-08-2016

Thank u soo much ..

29-03-2021

Finally, my problem was solved.

28-01-2023

You can also put `target="_blank"` in the form tag.

<form action=.. target="_blank">

This doesn't use any javascript.



We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2026   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer