JavaScript字符串中的字符数组
源程序:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>JavaScript字符串中的字符数组</title>
</head>
<body>
<script type="text/javascript">
var str = "www.dreamdu.com";
document.write(str+"的第五个字母是"+str);
document.write("<br />");
document.write(str+" = "+str[0]+str[1]+str[2]+str[3]+str[4]+str[5]+str[6]+str[7]+str[8]+str[9]+str[10]+str[11]+str[12]+str[13]+str[14]);
</script>
</body>
</html>
输出结果:
www.dreamdu.com的第五个字母是undefined
www.dreamdu.com = undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined
注意:
1、JavaScript字符串中的每个值可以使用字符数组的方式访问,注意字符串数组的索引是从0开始的。可以使用charAt()函数代替数组索引方式。(IE不支持字符数组,请使用charAt函数)
相关文档:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>验证数字最简单<a href="http://www.jb51.net/list/list_6_1.htm" tar ......
今天小编和大家探讨的是JavaScript中自定义函数的用法,下面示例中的 Checktriplet 函数以三角形的边长为参数。通过查看三条边的长度是否可以组成一个毕达哥拉斯三元组(直角三角形斜边长度的平方等于其他两条边长的平方和)来计算该三角形是否为直角三角形。实际测试时 checkTriplet 函数要调用另两个函数中的一个函数。
......
null, undefined
相同:
当一个变量的值是null, undefined时,表示:我们声明并定义了一个变量,仅仅是这个变量的值是null, undefined.
被调用者:
将null, undefined作为参数传入"JavaScript内置函数"时,不会出现异常,内置函数返回:null -> null, undefined->undefined
但typeof函数除外。
调 ......
页面自动刷新代码大全,基本上所有要求自动刷新页面的代码都有,大家可以自由发挥做出完美的页面。
1)
10表示间隔10秒刷新一次
2)
<script>
window.location.reload(true);
</script>
如果是你要刷新某一个iframe就把window给换成frame的名字或ID号
3)
<script>
window.navigate("本页面url"); ......