Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 致命错误语法错误,意外'<';,第1行应为文件结尾_Javascript_Html - Fatal编程技术网

Javascript 致命错误语法错误,意外'<';,第1行应为文件结尾

Javascript 致命错误语法错误,意外'<';,第1行应为文件结尾,javascript,html,Javascript,Html,有人能帮我确定为什么这个代码不起作用吗?它是直接从youtube教程复制的,所以我看不出哪里出了问题 谢谢大家! 我基本上想创建矩阵雨,但我自己版本的符号在其中。是否有人能够正确识别此代码的错误?我试着把它输入到 基质雨 /*基本重置*/ *{边距:0;填充:0;} /*在背景中添加一个黑色背景,使事情更清楚*/ 正文{背景:黑色;} 画布{显示:块;} var c=document.getElementbyId(“c”); var ctx=c.getCont(“2d”); //使画布全屏显示

有人能帮我确定为什么这个代码不起作用吗?它是直接从youtube教程复制的,所以我看不出哪里出了问题

谢谢大家!

我基本上想创建矩阵雨,但我自己版本的符号在其中。是否有人能够正确识别此代码的错误?我试着把它输入到


基质雨
/*基本重置*/
*{边距:0;填充:0;}
/*在背景中添加一个黑色背景,使事情更清楚*/
正文{背景:黑色;}
画布{显示:块;}
var c=document.getElementbyId(“c”);
var ctx=c.getCont(“2d”);
//使画布全屏显示
c、 高度=窗内高度;
c、 宽度=windows.innerWidth;
var ganoti=”诶比西迪艾弗艾尺艾勒艾娜吉吾艾儿"
//将字符串转换为单个字符数组
中文=chinese.split(“”);
var font_size=10;
var columns=c.width/font_size;//雨的列数
//一个drop数组-一个用于列
var下降=[];
//下面的x是x坐标
//1=落差的y坐标(每个落差的初始坐标相同)
对于(var=x;xc.height&&Math.random()>0.975)
滴[i]=0;
//递增Y坐标
滴落物[i]++
}
}
设置间隔(绘制,33);
}
}

phptester.net
需要PHP,你的代码是HTML,除了最后有多余的双

为什么在
之后有两个
结束标记?
for(var=x;x
是一个语法错误,你不应该在
var
x
之间有一个
=/code>(您的意思可能是
var x=0
)。该错误表明您在执行此操作时还存在其他一些问题,并且最后的
}
位置肯定不正确,但这是将其用作HTML时出现的第一个错误。在单行注释中添加换行符时,也会出现错误,
getElementbyId
而不是
getElementbyId(注意大写),等等。要么教程很差,要么(关于)您需要更加小心地复制它。有4或5个语法错误,结尾有冗余的double},不正确的for循环,不正确的getElementById,未知的函数getCont…谢谢您-这就是我正在复制的…谢谢您,我现在已经在html中尝试了,但它似乎仍然不起作用。
<DOCTYPE html>
<html>
    <head>
        <title>Matrix Rain</title>
        <style>
            /*basic resets */
            * {margin:0; padding: 0;}
            /* adding a black bg to the background to make things clearer */
            body {background: black;}
            canvas {display: block;}
        </style>
    </head>
    <body>
        <canvas id="c"></canvas>
        <script type="text/javascript">
            var c = document.getElementbyId("c");
            var ctx = c.getCont("2d");

            //making the canvas full screen
            c.height = window.innerHeight;
            c.width = windows.innerWidth;

            var ganoti = "诶比西迪艾弗艾尺艾勒艾娜吉吾艾儿"

            //converting the string into an array of single characters
            chinese = chinese.split ("");

            var font_size = 10;
            var columns = c.width/font_size; //number of columns for rain

            //an array of drops - one for column
            var drops = [];

            //x below is the x coordinate
            //1 = y co-ordinate of the drop(same for every drop initially)
            for (var = x; x < columns; x++)
                drops[x] = 1;

            //drawing the characters
            function draw () {
                //Black BG for the canvas
                //translucent BG to show trail

                ctx.fillStyle - "rgba(0,0,0,0.05)";
                ctx.fillRect(0,0, c.wdith, c.height);

                ctx.fillstyle = "DB7093";
                ctx.font = font_size + "px arial";

                //looping over drops
                for (var i = 0; i < drops.length; i++) {
                    var text = ganoti[Math.floor(Math.random()*ganoti.lenth)];

                    //x = i*font_size, y = value of drops[i]*font_size
                    ctx.fillText(text, i*font_size, drops[i]*font_size);

                    //sending the drop back to the top randomly after it has crossed 
                    screen // it should be in comment line
                    //adding a randomness to the reset to make the drops scattered on the 
                    Y axis // it should be in comment line

                    if (drops[i]*font_size > c.height && Math.random() > 0.975)
                        drops[i] = 0;

                    //incrementing Y coordinate
                    drops[i]++
                }

            }
            setInterval(draw, 33);
        </script>
    </body>
</html>
}
}