<form onSubmit="return false"> <input TYPE=BUTTON VALUE="Load" onClick="loadMol()"> </form> <script type="text/javascript" SRC="../../../marvin.js"></script> <script type="text/javascript"> <!--function loadMol() { if(document.MSketch != null) { document.MSketch.setMol("../../../mols-2d/caffeine.mol"); } else { alert("Cannot load molecule:\n"+ "no JavaScript to Java communication in your browser.\n"); } } msketch_name = "MSketch"; msketch_begin("../../..", 540, 480); msketch_param("scale", "60"); msketch_param("viewonly", "true"); msketch_end();//--> </script>
Note that the function that loads the molecule should not be named load(), because this name conflicts with a built-in JavaScript function in Netscape 6 (and later versions). That is why we named it loadMol() in this example.
In some cases you don't have the molfile in an URL, and it would be easier to pack it into the HTML as in the previous example. You can also do that in JavaScript.