Navigator 4.0 includes some new ways that client-side JavaScript
is embedded within HTML documents.
JavaScript 1.2 include support for "conditional
comments", a way of combining an HTML JavaScript entity with
an HTML comment. If the JavaScript expression within the
entity evaluates to true, then the comment
will be ignored, and any JavaScript code within it will be
executed (and any HTML text will be displayed). On the other
hand, if the expression evaluates to false,
then the conditional comment behaves like a normal HTML
comment, and its contents are ignored. In this way, you can
write JavaScript code that will only run on platforms that can
support it. The code below, for example, will only run if the
navigator.platform property (also new in
JavaScript 1.2) is equal to the string "win95".
Navigator 4.0 allows JavaScript code to be
embedded in an HTML file with the new
ARCHIVE attribute of the
<SCRIPT> tag. This is much like the
ARCHIVE attribute of the
<APPLET> tag that is used to embed
Java applets in a Web page. This attribute specifies an
archive file, in Java JAR format (the JAR format is a ZIP file
with the addition of a standardized manifest file). The
advantage of a JAR file for storing JavaScript code is that
files in a JAR archive can have digital signatures attached to
them. A digital signature guarantees the authenticity of the
signed code, and, if you trust the signer, this allows you to
trust their code as well.