Forum Moderators: open

Message Too Old, No Replies

Checkbox toggle in Chrome and Opera

         

Rain_Lover

9:18 am on Dec 29, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Steps to reproduce the issue:

  1. In your browser Settings select Continue where you/I left off under On startup.
  2. Navigate to the demo [demostudio.github.io].
  3. Check the checkbox.
  4. Edit the text.
  5. Close your browser and reopen it. Or duplicate/clone the tab.

Now as you see the checkbox is checked, but the textarea isn't colored.
I tried it in the latest version of Chrome and Opera in Windows 10. I'm not sure about Safari, but it probably behaves the same way.

Questions:

  • Why does it happen?
  • What's a cross-browser solution?

Fotiman

12:18 am on Jan 4, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I suspect that browsers store the state of checkboxes, but maybe not the state of inline styles. Since that demo changes the style "onchange", and setting the checked state of a checkbox programmatically doesn't trigger onchange events, I suspect you would need to add an onload event handler to run as well, which could then check the state of the checkbox.