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" /> 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
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.
set autocomplete = "off" with js also works well.
for example using jquery:
$(":checkbox").attr("autocomplete", "off"); 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).
or instead of f5 press enter on the address bar :)
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"> $ ("# ShowImage") prop ("checked", false) ;.
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 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.