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?
In Safari, the first alert incorrectly gives -1 for both indexOf() statements, whereas the second alert, after the string is forced to be a string, shows positive values for both indexOf() statements. In Firefox, both alerts correctly give positive values for the indexOf() statements. So apparently Safari is not recognizing the applet value as a String, whereas Firefox is so recognizing it. Any ideas why? We have always treated this value as a String; this problem appears to be fairly new.
No clue--but I'm always suspicious when things look and act like one object but are something else. You could always try typeof foo and see what it actually is.
Joined: Dec 18, 2008
You nailed it. I added a typeof command to the alert. Safari tells me that the variable retrieved from the applet is an object. Firefox 3.0 for Mac tells me that it is a string. Internet Explorer 7.0 for PC also recognizes it as a String. Interestingly, Firefox 2.0 for PC recognizes it as an object, but is still able to find the substrings as if it were a string.
So now, why is Safari not recognizing the object as a string, or converting it into a string when confronted with the indexOf() command, as Firefox 2.0 for PC appears to do?