标题:函数运行不了,求助
只看楼主
丶木清丶
Rank: 2
等 级:论坛游民
帖 子:7
专家分:22
注 册:2017-11-27
 问题点数:0 回复次数:2 
函数运行不了,求助
这段函数运行不了,不明白哪里出错了,请大家帮忙看一下,感谢。

//loops.html文件
<html>
    <head>
        <title>
            LOOPS Example
        </title>
    </head>
    <body>
        <h1>Loop Example</h1>
        <p>Enter a series of names,I will then display them in a nifty numbered list.</p>
        <script language="javascript" type="text/javascript" scr="loops.js"></script>
    </body>
</html>

//loops.js文件
// JavaScript source code
names = new Array();
i = 0;
do {
    next = window.prompt("Enter the Next Name", "");
    if (next > " ")
        names[i] = next;
    i = i + 1;
} while (next > " ");
document.write("<h2>" + (names.length) + "names entered.</h2>");
document.write("<ol>");
for (i in names)
{
    document.write("<li>" + names[i] + "<br>");
}
document.write("</ol>");
搜索更多相关主题的帖子: 函数 运行 next document write 
2017-11-28 23:18
leeqihero
Rank: 3Rank: 3
等 级:论坛游侠
威 望:7
帖 子:122
专家分:135
注 册:2016-3-24
得分:0 
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<h1>Loop Example</h1>
<p>Enter a series of names,I will then display them in a nifty numbered list.</p>
</body>
<script>
names = new Array();
i = 0;
do {
    next = window.prompt("Enter the Next Name", "");
    if (next > " ")
        names[i] = next;
    i = i + 1;
} while (next > " ");
document.write("<h2>" + (names.length) + "names entered.</h2>");
document.write("<ol>");
for (i in names)
{
    document.write("<li>" + names[i] + "<br>");
}
document.write("</ol>");
</script>
</html>
2018-03-01 08:30
leeqihero
Rank: 3Rank: 3
等 级:论坛游侠
威 望:7
帖 子:122
专家分:135
注 册:2016-3-24
得分:0 
<html>
<head>
    <meta charset="UTF-8">
</head>
<body>
<h1>Loop Example</h1>
<p>Enter a series of names,I will then display them in a nifty numbered list.</p>
</body>
<script>
var names = [];
var n=""
var html="";
while(1){
    n = window.prompt("Enter the Next Name", "");
    if (!n) break;
    names.push(n);
};
html+="<h2>" + (names.length) + "names entered.</h2><ol>";
for (var i in names){
    html+="<li>" + names[i] + "<br>";
}
html+="</ol>"
document.body.innerHTML+=html;
</script>
</html>
2018-03-01 08:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-482920-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.498605 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved