please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

String.indexOf() Method

Name

String.indexOf() Method---search a string

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

string.indexOf(substring)
string.indexOf(substring, start)

Arguments

substring

The substring that is to be searched for within string.

start

An optional integer argument that specifies the position within string at which the search is to start. Legal values are 0 (the position of the first character in the string) to string.length-1 (the position of the last character in the string). If this argument is omitted, then the search begins at the first character of the string.

Returns

The 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.

Description

String.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, then 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, then String.indexOf() returns -1.

Bugs

In Navigator 2.0 and 3.0, if start is greater than the length of string, then indexOf() returns the empty string rather than -1.

See Also

"String", "String.charAt()", "String.lastIndexOf()", "String.substring()"


Previous Home Next
String.fontsize() Book Index String.italics()

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/java/script/definitive/refp_363.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/11/27 00:33,
TOP NEW HELP FIND: 
3.138.135.4:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/Techref/language/java/script/definitive/refp_363.htm"> [Chapter 21] Reference: String.indexOf()</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .