MarvinSketch Example - Loading a molecule in visualization mode, using magnification

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 selecting View > Toolbar in the applet. We have also used the autoscale parameter of the applet to fit the molecule into the window.

<script type="text/javascript" SRC="../../../marvin.js"></script>
<script type="text/javascript">
<!--
msketch_begin("../../..", 540, 480);
msketch_param("mol", "../../../mols-2d/caffeine.mol");
msketch_param("viewonly", "true");
msketch_param("autoscale", "true");
msketch_end();
//-->
</script>
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.