To support the use of Marvin Applets, ChemAxon provides utility functions that help to
overcome the problems of working with HTML tags. These utilities are stored in the
marvin.js JavaSript file.
The live MarvinSketch applet embedded in the HTML page appears as follows:
To achieve this the following lines should be included in the HTML page:
<script LANGUAGE="JavaScript1.1" SRC="../../../marvin.js"></script>
<script LANGUAGE="JavaScript1.1">
<!--
msketch_begin("../../..", 540, 480); // arguments: codebase, width, height
msketch_end();
//-->
</script>
Sun recommends to include applets in HTML pages by using the APPLET tag:
<applet CODEBASE="../../.." ARCHIVE="jmarvin.jar"
CODE="JMSketch" WIDTH=540 HEIGHT=480>
<strong>Your browser does not support the applet tag.</strong>
</applet>
The CODEBASE option specifies the directory of
the Marvin binaries relative to the HTML file. This HTML file is in a
subdirectory of the Marvin binaries directory, that's why we use
"../../.." here.
The ARCHIVE option is used to preload resources
that can significantly improve the performance of applets.
These resources are packed into a compressed JAR file, jmarvin.jar.
The CODE attribute specifies the name of the applet class.
The text "Your browser does not support the applet tag." is
displayed if someone visits the web page with a browser that is not Java
compatible.
However there is a note in The Java Tutorials, that makes the situation more complicated:
Note: The HTML specification states that the applet tag is deprecated, and that you should use the object tag instead. However, the specification is vague about how browsers should implement the object tag to support Java applets, and browser support is currently inconsistent. It is therefore recommended that you continue to use the applet tag as a consistent way to deploy Java applets across browsers on all platforms.
There are three possible platform dependent solutions available overall:
<applet ARCHIVE="jmarvin.jar"><embed><object>The embed tag is used to deploy applets that are to be used only
with the Mozilla family of browsers (including FireFox), the object
tag with Internet Explorer, while the applet tag is general.
However with the applet tag, the required Java Plug-in cannot be automatically
downloaded and installed while it can with the two other solutions.
The most reliable way among these is to use the applet tag as Sun recommends.
The next example introduces the use of applet parameters.