|
|
Posted on
2009-03-18 22:30
东南西北风
阅读( 192)
评论()
收藏
举报
 Code
<script language="javascript">
for(i=65; i<=90; i++) {
//取得指定的Unicode值所表示的字符
ch = String.fromCharCode(i);
document.write(ch);
}
//搜索字符串
str = "javaScript";
ch = "s";
//从左到右的第一满足要求的位置
index = str.indexOf(ch);
//从右到左的第一满足要求的位置
lastIndex = str.lastIndexOf(ch);
if(index != -1) {
document.write("字符" + ch + "所在的位置:" + index);
} else {
document.write("没有搜索到你要查找的字符串");
}
</script>
|