Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

weird failure of javascript indexOf() command

When a JSP page that I cowrote acquires a certain value for the variable molstruct, this Javascript code:

alert("molstruct.indexOf('z3=') = " + molstruct.indexOf('z3=')
+ ", molstruct =\n" + molstruct);

gives the alert below. As you can see, this particular value of molstruct contains the string 'z3=' about 13 lines down, but molstruct.indexOf('z3=') is returning the value -1. !?!?! I'm using Safari 4.0.3 on MacOS 10.5.8. Any explanations? I don't know whether this problem is exclusive to Safari, but the person who reported it to me was also using Safari.

molstruct.indexOf('z3=') = -1, molstruct =
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10"
elementType="C C C C C C C O H H"
x3="-15.785 -16.183600000000002 -14.297500000000001 -12.8099 -12.679124923706055 -14.696100000000001 -15.225475076293947 -11.5715 -12.756699542236328 -15.074450534057618"
y3="6.2081 4.7206 6.6067 6.01560036239624 4.431849828338623 5.1192 7.997949942779542 6.923100000000001 8.291875305175783 3.1038001430511475"
z3="0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a1 a3" order="1" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a4 a5" order="1" />
<bond atomRefs2="a5 a6" order="1" />
<bond atomRefs2="a6 a2" order="1" />
<bond atomRefs2="a3 a7" order="1" />
<bond atomRefs2="a7 a6" order="1" />
<bond atomRefs2="a4 a8" order="2" />
<bond atomRefs2="a3 a9" order="1">
<bondStereo>W</bondStereo>
</bond>
<bond atomRefs2="a6 a10" order="1">
<bondStereo>H</bondStereo>
</bond>
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>

MacBook Pro, Mac OS X (10.5.8)

Posted on Oct 11, 2009 5:57 PM

Reply
1 reply

weird failure of javascript indexOf() command

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.