Stephen, you are almost there -- just one issue: On Tue, Aug 11, 2015 at 2:59 PM, Stephen Hillier < stephen.hill...@hutton.ac.uk> wrote:
> > > $(document).ready(function() { > > > > Info = { > > width: 400, > > height: 400, > > debug: false, > > j2sPath: "j2s", > > color: "0xC0C0C0", > > disableJ2SLoadMonitor: true, > > disableInitialConsole: true, > > addSelectionOptions: true, > > serverURL: " > http://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php", > > use: "HTML5", > > readyFunction: null, > > script: "load $caffeine" > > } > > > > $("#mydiv").html(Jmol.getAppletHtml("jmolApplet0",Info)) > > > > }); > > > > Very nice -- the applet is being created after the page is loaded. This is the way to go. > > </script> > > </head> > > <body> > > <span id=mydiv></span> > > <a href="javascript:Jmol.script(jmolApplet0, 'spin on')">spin on</a> > > > > <a href="javascript:Jmol.script(jmolApplet0, 'spin off')">spin off</a> > > This next is JavaScript, so you need a <script> tag here > > > *Jmol.jmolCheckbox(jmolApplet0, "spin on", "spin off", "toggle spin") * > > and </script> here. Note that you have not defined jmolApplet0 yet --- that happens after the page is loaded. Two options: 1) define in the header the name as the same as the string jmolApplet0 = "jmolApplet0" 2) just use "jmolApplet0" in quotes here. JSmol will convert it later: <script> *Jmol.jmolCheckbox("jmolApplet0", "spin on", "spin off", "toggle spin") * </script> > > </body> > > </html> > > > > You can avoid all script tags in the body if you want by using Jmol.setDocument(0) in your $(document).ready() method and building all the buttons there. So, for example: ... <head> ... $(document).ready(function() { ... $("#mydiv").html(Jmol.getAppletHtml("jmolApplet0",Info)) ... Jmol.setDocument(0); // tells Jmol object to just return HTML; doesn't use document.write var s = Jmol.jmolLink(jmolApplet0, "spin on", "spin on") + " " + Jmol.jmolLink(jmolApplet0, "spin off", "spin off") + " " + *Jmol.jmolCheckbox(jmolApplet0, "spin on", "spin off", "toggle spin")* $("#buttondiv").html( *s)* }); ... </head> <body> ... <span id=mydiv></span> <span id=buttondiv></span> Bob
------------------------------------------------------------------------------
_______________________________________________ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users