Every now and then I come across some simple problem that leads me to
believe I have missed some fundamental understanding of How Things Work.
This is such a case.
URL:
http://stl.beallsprings.org/conservation%20easement.html
(Yes, there are unencoded ampersands on the page and a few missing alt=
attributes. I'll be fixing those while you contemplate the actual
question.)
In the upper right corner of the page is a checkbox, created via
JavaScript in the body of the HTML thus:
document.write('<input type="checkbox" id="notecheck" checked
onclick="filter()">Show annotations');
Note the 'checked' entry, which causes the box to be checked when it is
created. Consistent with that check, the annotations on the page (in a
sans-serif font) are visible.
Now UNcheck the box. The annotations go away (and the background color
changes to a sort of yellow as a reminder that you are looking at the
original document, verbatim.) All is well.
Now refresh the page. Bummer. The page, as expected, again contains the
annotations (and the white background), but the checkbox is still
unchecked, so the two are now out of sync.
When I refresh a page, shouldn't the JavaScript be executed again? And,
if so, shouldn't the 'checked' entry cause the box to again be initialized
in the checked state?
An explanation would be appreciated, but even better would be a pointer to
a technical spec where this is discussed.
I have developed a workaround, which is to explicitly check the box within
a body onload=function which does seem to get executed on a page refresh.
An example, on a rather more complex page with several checkboxes, is at
http://stl.beallsprings.org/Timeline.html
Chris Beall