| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1992 人关注过本帖
标题:函数运行不了,求助
只看楼主 加入收藏
丶木清丶
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
快速回复:函数运行不了,求助
数据加载中...
 
   



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

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