Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent new window/tab opening after form post

Tags:

html

post

forms

I have a form submission like:

<form target="_blank" id="discussionForm" method="POST" enctype="multipart/form-data" action="<%=discussionURL%>">

Then I have a Submit button at the end. This works, and it posts to my db, but it opens a new tab with the url of the service that I'm using to post to the db. I don't want that new tab to open. I tried playing around with different targets, but I thought _blank would work. Any suggestions?

like image 212
Zach Lucas Avatar asked Sep 14 '25 03:09

Zach Lucas


1 Answers

Remove target attribute and it should be fine.

target="_blank" actually means it should open in a new tab/window.

Documentation (please always read the docs first)

like image 101
kapa Avatar answered Sep 16 '25 16:09

kapa