# JS not resubmit form if reload page

**URL:** <https://forum.freecodecamp.org/t/js-not-resubmit-form-if-reload-page/328433>\
**Category:** General\
**Created:** [November 26, 2019, 3:40pm UTC](https://forum.freecodecamp.org/t/js-not-resubmit-form-if-reload-page/328433 "2019-11-26T15:40:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fratozzi](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@Fratozzi](https://forum.freecodecamp.org/u/Fratozzi)\
**Post date:** [November 26, 2019, 3:40pm UTC](https://forum.freecodecamp.org/t/js-not-resubmit-form-if-reload-page/328433/1 "2019-11-26T15:40:01Z")

</div>

Hi everyone!  
I have a file in js structured like this:

```auto
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}

```

This function blocks the pop-up that requires the module to be sent back to the update after sending the form. Works on all devices and browsers less than for Safari. I was wondering if there is an alternative…

Thanks

---

<div class="post-metadata">

**Author:** ![chuckadams](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/chuckadams/32/109651_2.png) [@chuckadams](https://forum.freecodecamp.org/u/chuckadams)\
**Post date:** [November 26, 2019, 3:45pm UTC](https://forum.freecodecamp.org/t/js-not-resubmit-form-if-reload-page/328433/2 "2019-11-26T15:45:17Z")

</div>

The old-school solution to this is to have the backend send a 302 redirect to the destination page after it receives the post. The javascript solution is nice when you don’t have the cooperation of the backend.

---

<div class="post-metadata">

**Author:** ![Fratozzi](https://avatars.discourse-cdn.com/v4/letter/f/e19b73/32.png) [@Fratozzi](https://forum.freecodecamp.org/u/Fratozzi)\
**Post date:** [November 26, 2019, 4:19pm UTC](https://forum.freecodecamp.org/t/js-not-resubmit-form-if-reload-page/328433/3 "2019-11-26T16:19:11Z")

</div>

the problem is that I don’t have to redirect myself to another page but always remain in the same post. So when I finish the post procedure I don’t do a header()

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 11:32am UTC](https://forum.freecodecamp.org/t/js-not-resubmit-form-if-reload-page/328433/4 "2021-01-16T11:32:09Z")

</div>

Closed on January 16, 2021, 11:32am UTC


