Thanks, Tim. OK, the setTimeout() issue is a hard one to track down. I think I should have qualified this as involving links when there is a defined messageCallback function. That was the situation -- not just regular links. I'm the one who notices it because I'm one of few people employing messagecallback functions. It's specifically with that complication that issues arise, I think.
My reference is
http://sourceforge.net/mailarchive/message.php?msg_id=10306527
Here are two examples for comparison:
http://www.stolaf.edu/people/hansonr/jmol/applet/mscalc/view.htm http://www.stolaf.edu/people/hansonr/jmol/applet/mscalc/view_NOSETTIMEOUT.htm
I promise to leave these alone now so that they aren't moving targets! In my experimentation, the second crashes Opera 7.52. The only difference is that the scripts in view.htm are sent out using
setTimeout("sendscript('"+escape(scmd)+"',1)",100)Here's the whole function:
function sendscript(scmd,isnow){
//send script to applet as setTimeout string -- critical for Opera
if(isnow){
scmd=unescape(scmd)
}else{
setTimeout("sendscript('"+escape(scmd)+"',1)",100)
return
} if(document[jmoltarget]){
document[jmoltarget].script(scmd)
}else if(document.getElementById(jmoltarget)){
var d=document.getElementById(jmoltarget)
d.script(scmd)
}else if(document.info[jmoltarget]){
document.info[jmoltarget].script(scmd)
}else{
alert("Can't find applet")
}
}
Thanks for the escape() idea!
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
"Imagination is more important than knowledge." - Albert Einstein
------------------------------------------------------- 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

