Can I prevent / avoid warning when reloading the form on my page?

I have a simple form on my page as shown.

Is there a way to avoid the warning ?. I find this annoying, and in my case, I don’t lose any important information if I reload the form.

Are you sure you want to reload the page

<form name="theForm" method="get"> <!-- Changed from "post" to "get" but alert keeps showing --> Start Point ( <input type="text" name="pt0x" size="4" onkeydown="keyDownPt(event, document.theForm.pt0x.value, 0, 'x')"/>, <input type="text" name="pt0y" size="4" onkeydown="keyDownPt(event, document.theForm.pt0y.value, 0, 'y')"/> ); </br> ... </form> 

I don’t have a submit button because I am updating my onkeydown event. Could this be the reason?

+4
source share
3 answers

Since you are not really doing anything with this, you can completely get rid of the form.

EDIT for completeness: Without using a form tag, HTML is valid and validated as strict HTML4, HTML5, and XHTML transitions. W3C validator is here .

+1
source

Use GET as a method for the form tag instead of POST.

Since POST is designed to β€œupload” data to the server, the browser will rightfully warn the user about the form being re-processed, but if you just GET the data, the browser assumes that the safe action is repeated.

EDIT : I am not reading the dialog correctly in the question. This is not about reselling, but about discarding form data ... Try using GET instead of POST anyway (if you are not already doing this), see if this has an effect.

EDIT2 : I would be surprised if there was any simple way to disable it using javascript (maybe the user could disconnect in the browser), as this is a reminder that you are about to reset the data. If the user wants to reload the page, the browser warns that the form will be discarded, but the user can dismiss it.

In any case, this should not be a problem. If for some reason you need to restart the application for actual production, try rewriting the program to work without rebooting (as this may lead to the browser reloading the code). For instance. if you want to reboot only to form reset, just add a reset button.

+2
source

I think I’ll try to disable the submit button, since you are not going to publish data in the first place.

An easy (and ugly) way to do this is to add false return statuses to the onsubmit form handler:

 <form onsubmit="return false;"> 

OK, good luck!

0
source

Source: https://habr.com/ru/post/1382218/


All Articles