Categories
HTML

How to submit an HTML form without redirection?

Spread the love

Sometimes, we want to submit an HTML form without redirection.

In this article, we’ll look at how to submit an HTML form without redirection.

How to submit an HTML form without redirection?

To submit an HTML form without redirection, we can redirect to an invisible iframe.

For instance, we write

<iframe name="dummyframe" id="dummyframe" style="display: none"></iframe>

<form action="submitscript.php" target="dummyframe">...</form>

to add a hidden iframe with

<iframe name="dummyframe" id="dummyframe" style="display: none"></iframe>

And then we set the form’s target attribute to the ID of the hidden iframe to redirect to it after form submission is done.

Conclusion

To submit an HTML form without redirection, we can redirect to an invisible iframe.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *