Jeff,

The mistake here is timing. You cannot query an applet while the page is
loading (prior to </body> and completion of applet initialization). In some
cases this crashes browsers; in others it just causes an error; in others it
permanently disables the applet communication.

The simple fix is to place the JavaScript code in a function defined in the
<head> block, and then add a JavaScript call to that function in the
start-up Jmol script, after the file is loaded. No need for form tags.

<head>
    <script type="text/javascript">
function appletReady() {
 var atomSetArray = jmolGetPropertyAsArray("atomInfo","atomno<5");
 alert (atomSetArray[0].info);
}
    </script>
</head>
<body>
    <script type="text/javascript">
      jmolInitialize("jmol");
      jmolApplet(500, "load ../Jmol/jmol/models/1bf3.pdb;javascript
appletReady()");

>     </script>
> </body>
>



On Wed, Aug 20, 2008 at 2:29 PM, Jeff Hansen <[EMAIL PROTECTED]> wrote:

> I'm having difficulty getting info from the Jmol applet.  Here is my
> code (basically copied from a post from Bob Hanson):
>
> <body>
>   <form>
>     <script type="text/javascript">
>       jmolInitialize("jmol");
>       jmolApplet(500, "load ../Jmol/jmol/models/1bf3.pdb");
>          var atomSet =
> document
> .getElementById("jmolApplet0").getProperty("atomInfo","atomno<5");
>          alert (atomSet.get(0).get("info"));
>     </script>
>   </form>
> </body>
>
> This code displays the applet with the molecule loaded but does not
> display the alert box at all.  I must admit I am relatively new to
> javascript.  Any help getting started with this would be most
> appreciated.  Ultimately I am looking to get other types of info out
> such as the energy of a molecule from a spartan file.  Thought I would
> start with something simple that has been done, but I'm having some
> trouble with it.
>
> Thanks in advance for any help you can give.
>
>
> ***********************************************
> Jeff Hansen
> Department of Chemistry and Biochemistry
> DePauw University
> 602 S. College Ave.
> Greencastle, IN 46135
> [EMAIL PROTECTED]
> ***********************************************
>
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>



-- 
Robert M. Hanson
Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr


If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to