学过C语言的人,对此应该熟悉,完全是一样的,一个简单的while循环例子:
简单的while循环
<html>
<head>
<title>简单的while循环例子</title>
<script language="javascript">
<!--hide me
var password="tograce";
var answer;
while (answer!=password)
{
answer=prompt("input the password(tograce)","");
}
//show me-->
</script>
</head>
<body>
</body>
</html>
下面代码功能是一样的:
while loop
var a_line="";
var loop = 0;
while (loop < width)
{
a_line = a_line + "x";
loop=loop+1;
}
for loop
var a_line="";
for (var loop=0; loop < width; loop++)
{
a_line = a_line + "x";
}
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |