Friday, December 11, 2009

IndexOf String Function 01

JavaScript IndexOf string function returns the starting index of the specified string pattern from the provided string. JavaScript IndexOf function starts traversing the string from left side of the provided string and returns the first occurrence of the specified string pattern. Try the sample below:
<html>
<head>
    <title>Javascript indexOf String Function 01</title>
</head>
<body>

<script type="text/javascript">

var myString = new String();

myString = "This is a sample text to test javascript function.";

document.write(myString.indexOf("s"));
document.write("<br />");

document.write(myString.indexOf("te"));
document.write("<br />");
</script>

</body>
</html>
--
ఇట్లు మీ,
చంద్రశేఖర్.

No comments: