In a web page I’m using a javascript triggered by the onclick
event of a checkbox to, first, enable/disable a fieldset
html element and, second, change accordingly the background color of the legend
element to somehow communicate the fieldset
‘s enabled/disabled state. When navigating back to a previous page in Chrome what I noticed is that checkboxes in a page are first loaded in their default state on that page and then they are brought back to whatever state they had when navigation away from that page took place. Now, if when navigating back to a page I query the checked state via the $(document).ready
method I always get the default state for all checkboxes because the document ready event occurs before checkboxes are brought back to their final state. This post confirms the behavior described above and suggests the window.onpageshow
event (instead of the $(document).ready
) to query the final state of checkboxes.
It the window.onpageshow
event the only and correct option to keep consistency on pages even when navigating back on chrome? Any other option?