Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

indexOf() has died on me!

Status
Not open for further replies.

Pyrrhus

Technical User
Dec 18, 2001
112
AU
I have a web site that has been working for years using the JS code in question. Suddenly it is malfunctioning and the problem seems to be that indexOf is returning values of -1 in place of the formerly valid values.

The actual code is:

var firstchar=decodedscorestring.indexOf("s0101");
var nextchar=decodedscorestring.indexOf("s0201");

Anyone have any ideas at all??

Thanks.
 
You've checked the value of your decodedscorestring, right?
 
note:
indexOf is case sensitive...

Known is handfull, Unknown is worldfull
 
-1 is returned when the string paramater cannot be found. As theboyhope suggested, I would check the value of the string being tested and/or the string being passed to the function.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Thanks to the 3 of you for your suggestions. As usual it turned out to be something else. The string had been retrieved from a js cookie, and somehow I had created a bogus cookie which was returning the incorrect string.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top