> I've posted a very simple test for accessing the JmolApplet.  it does away
> with almost all complexity that can cloud this issue.  you can see it
> here:
>
> <http://dev.molvisions.com/debugging/jmolcalls.html>
>
> it includes three methods:
>
> 1. getElementById
> 2. document.appletname
> 3. document.applets[]

Tim,

The code below is what that I use in Jmol.js. Internally it calls
_jmolFindApplet with an applet name and it searches ... first in the
current window and then starting at the top.

I am not using getElementById but instead use document.applets[] and
document[appletname] (which is exactly the same as document.appletname but
works better for me since appletname is a parameter)


Miguel


function _jmolFindApplet(target) {
  // first look for the target in the current window
  var applet = _jmolSearchFrames(window, target);
  if (applet == undefined)
    applet = _jmolSearchFrames(top, target); // look starting in top frame
  return applet;
}

function _jmolSearchFrames(win, target) {
  var applet;
  var frames = win.frames;
  if (frames && frames.length) { // look in all the frames below this window
    for (var i = 0; i < frames.length; ++i) {
      applet = _jmolSearchFrames(frames[i], target);
      if (applet)
        break;
    }
  } else { // look for the applet in this window
    var doc = win.document;
// getElementById fails on MacOSX Safari & Mozilla
    if (doc.applets)
      applet = doc.applets[target];
    else
      applet = doc[target];
  }
  return applet;
}




-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id5hix
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to