Show Image

Why is the checkbox selected when reloading the page?

I reload the web page with the following code:

<label for="showimage">Show Image</label> <input id="showimage" name="showimage" type="checkbox" value="1" /> 

Despite the fact that the HTML remains the same in the browser for each page reload, the checkbox always takes a verified value when reloading. In other words, if the user checks the checkbox and reloads, the checkbox is still checked.

Does caching happen here?

Change I tried the Gordon Bell solution below and found that this still happens even after deleting the value = "1". Anything else I can skip?

 <label for="showimage">Show Image</label> <input id="showimage" name="showimage" type="checkbox" /> 
+72
firefox
Nov 18. '08 at 19:16
source share
9 answers

Yes, I believe this is caching. I see this behavior in Firefox, for example (not Safari, for what it's worth :)).

you can reload the page and bypass the cache (in Firefox) using CTRL - SHIFT - R , and you will see that the check value is not transferred (normal CTRL - R will capture information from the cache, however)

edit . I was able to disable this server part in Firefox by setting the cache control header:

 Cache-Control: no-store 

this seems to disable Firefox's "remember form values" function

+34
Nov 18 '08 at 19:28
source share

Add autocomplete="off" to the form element on the page. The downside is that this is invalid XHTML, but it fixes the problem without any minimized javascript.

+138
Jan 22 '09 at 22:39
source share

set autocomplete = "off" with js also works well.

for example using jquery:

 $(":checkbox").attr("autocomplete", "off"); 
+29
Jul 14 '09 at 4:03
source share

This is a good feature of Firefox: if you type something, but reload the page, the text remains in the text area. The same goes for the other settings you have selected.

Alas, it does not work in SO (possibly reset by JS) and the dead end of browsers like IE ...

What offers a solution: if you really need to do this, reset the form with JS. form.reset () can do the job (acts like a reset button).

+1
Nov 18 '08 at 21:04
source share

or instead of f5 press enter on the address bar :)

0
Nov 19 '08 at 12:47
source share

This may be due to browser caching - very useful for static websites that don't change too often, very bad for dynamic web applications.
Try with these two meta tags in the main section of the page. The second meta tag for older browsers (IE5), which do not recognize the no-cache meta tag, and although different results give the same result: each request is sent to the server.

 <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> 
0
Nov 19 '08 at 13:54
source share

$ ("# ShowImage") prop ("checked", false) ;.

0
May 15 '17 at 7:25 a.m.
source share

public idea to solve this problem

make form and reset button

 <form> <checkbox> <reset> </form> $(reset).trigger("click");//to clear the cache and input $(checkbox).trigger("click");//to mark checkbox 
0
Sep 06 '17 at 20:59 on
source share

This is an old question, but still an active issue for Firefox. None of the answers that I tried to solve did not solve, but what solved it for me was just like this:

  document.getElementById('formId').reset(); 

This simply resets the form to its default settings each time the page loads. Not perfect, as you lose granular control, but this is the only thing that solved this for me.

0
Jun 25 '19 at 18:12
source share



All Articles