Blue said:
HTML commenting to hide the script from JS incompatible
browsers,
But its context follows a STYLE element that does not feature similar
"hiding" and the browsers that don't understand SCRIPT don't understand
STYLE either (so they write the unhidden STYLE content into the
displayed text output in the same way as they would write an unhidden
SCRIPT into the content).
although it doesn't seem to be included in scripts on this
group. What's the reason for the aversion to script hiding?
It represents people doing things without understanding what they are
doing or why they are doing it; a mystical incantation rather than a
design decision.
Realising exactly how old the browsers that suffer from not
understanding SCRIPT elements are immediately makes it obvious that this
technique is no longer necessary (and has not been for some considerable
time). Using it in a script that goes on to employ the W3C DOM Core -
getElementById - method without verifying that it is implemented in the
current environment (or attempting to provide any safe fall-back
emulation) makes it doubly clear that the "hiding" is not understood, as
two generations of browsers occupy the gap between the introduction of
client-side scripting and the first implementations of W3C DOM methods
in browsers. Leaving a script that appears to be worrying about ancient
and extinct browsers but that will predictably error-out on the older of
the browsers that are still in use.
An evident contradiction that is re-enforced again by the realisation
that the script has been predicated on an ability to switch the CSS
display property and have the browser dynamically respond to the action.
Making it a script that is needlessly designed to give an unusable GUI
on javascript disabled browsers, browsers pre-dating the W3C DOM and W3C
standard browsers that are not sufficiently dynamic to facilitate the
switching of the display property (such as Opera <= 6 and NetFront).
After that it seems a bit superfluous to be trying to prevent some
dinosaur browser from writing the contents of a script element into its
displayed text.
Richard.