AvailabilityJavaScript 1.0; JScript 1.0, ECMAScript v1 Synopsisstring.indexOf(substring) string.indexOf(substring,start) Arguments
ReturnsThe position of the first occurrence of substring within string that appears after the start position, if any, or -1 if no such occurrence is found. DescriptionString.indexOf( ) searches the string string from beginning to end to see if it contains an occurrence of substring. The search begins at position start within string, or at the beginning of string if start is not specified. If an occurrence of substring is found, String.indexOf( ) returns the position of the first character of the first occurrence of substring within string. Character positions within string are numbered starting with zero. If no occurrence of substring is found within string, String.indexOf( ) returns -1. BugsIn JavaScript 1.0 and 1.1, if start is greater than the length of string, indexOf( ) returns the empty string, rather than -1. See AlsoString.charAt( ), String.lastIndexOf( ), String.substring( ) |