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:
The<applet CODEBASE="../../.." ARCHIVE="appletlaunch.jar" CODE="JMSketchLaunch" WIDTH=540 HEIGHT=480> <strong>Your browser does not support the applet tag.</strong> </applet>
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.ARCHIVE
option is used to preload resources
that can significantly improve the performance of applets.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="appletlaunch.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.
Before version 5.2.1 the jmarvin.jar
compressed JAR file was used as applet resource.
The appletlaunch.jar
file contains a wrapper to the binaries stored in jmarvin.jar
.
It performs loading of the applet resources in the background while displaying a splash screen.
It is also possible to use jmarvin.jar
directly. This usage is sometimes referred to as
old behavior.
The same behavior with the<script LANGUAGE="JavaScript1.1" SRC="../../../marvin.js"></script> <script LANGUAGE="JavaScript1.1"> <!--msketch_begin("../../..", 540, 480, true); // arguments: codebase, width, height, true means the old behavior msketch_end();//--> </script>
<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 next example introduces the use of applet parameters.