MarvinSketch Example 3.1

This molecule is loaded by the applet from a file named "caffeine.mol" which resides in the directory "../../mols-2d" (relative to the URL of this document).

The applet above was started in visualization (view only) mode (i.e., the editing buttons cannot be seen). You can get into editing mode by pressing the top left button in the AWT applet, or selecting View/Toolbar in the Swing applet. We have also used the autoscale parameter of the applet to fit the molecule into the window.

<script LANGUAGE="JavaScript1.1" SRC="../../marvin.js"></script>
<script LANGUAGE="JavaScript1.1">
msketch_begin("../..", 460, 380);
msketch_param("mol", "../../mols-2d/caffeine.mol");
msketch_param("viewonly", "true");
msketch_param("autoscale", "true");
Note that the initial molecule and the magnification can also be set runtime, with the setMol and the setScale public methods.

Usually this simple method of loading a molecule works well enough. However, sometimes it is better if the applet does not make any network connection, for instance if the user's computer is off-line, and the page with the applet comes from the browser's cache. The next example shows the solution for this situation.