Oh, one more:

9. In any callback function ALWAYS convert the
message to a string explicitly using something like:

function mycallback(whichapplet,themessage){
  var strMessage=""+themessage

...

}

This caused me much grief in the past; I suppose it might be fixed, but somehow,
sometimes, strings weren't being passed as strings and all hell broke out when one did something like


 if(themessage.indexOf("Atom")==0)

Bob



timothy driscoll wrote:
On 2005-04-20 (12:12) Bob Hanson wrote:


Thanks to all for feedback on the test pages:

http://www.stolaf.edu/people/hansonr/jmol/applet/mscalc/view.htm


<snip>

hi Bob,

thought I'd add my $0.02 on one of your lessons learned:


5. Another issue involves setTimeout() and scripting an applet. If
you are going to script the applet using a link, that is: <a
href=javascript:....>, or if you want to support Opera at all, it is
imperative that you use setTimeout() to trigger the event. This
means that using

<a href="javascript:document.jmol.script('xxxx')">

is a sure-fire way to have user problems. I recommend

<a href="javascript:doscript('whatever')">

and then creating a function that starts a new thread using

setTimeout("applet.script('"+whatever+"',100)

I'm pretty sure jmol.js does NOT do this yet, so jmolLink() may not
work on all platforms, and ANY scripting/callbacks may not work some
Opera browsers. I can confirm that this is a problem even with
messageCallbacks (not just links) under Opera 7.52.




I'd be interested to see a test case for this. I have never had a problem calling jmol.script() directly from an anchor as you describe, and I do it an awful lot. I do not test in Opera, so it may very well be a problem there, but I do test in FF, Moz, NS, Safari (Mac), and IE (Win). do you have a simple example page that I can view?

I do use setTimeout, in case I'mm caught trying to send a script to Jmol when 
it is either not loaded or busy.  it simply loops until Jmol is ready, then 
sends the queued commands.  this works great.

one lesson I would add is this:

I have found it very helpful to escape Jmol command strings as they pass thru 
javascript functions, then unescape them right before they pass to Jmol.  this 
has helped me solve lots of nagging problems.



regards,

tim

-- Robert M. Hanson, [EMAIL PROTECTED], 507-646-3107 Professor of Chemistry, St. Olaf College 1520 St. Olaf Ave., Northfield, MN 55057 mailto:[EMAIL PROTECTED] http://www.stolaf.edu/people/hansonr




------------------------------------------------------- This SF.Net email is sponsored by: New Crystal Reports XI. Version 11 adds new functionality designed to reduce time involved in creating, integrating, and deploying reporting solutions. Free runtime info, new features, or free trial, at: http://www.businessobjects.com/devxi/728 _______________________________________________ Jmol-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to