超出我想象的简单画布

use*_*943 -3 html javascript html5-canvas

    <html>
<head>
<script>
  function draw() {
    var canvas = document.getElementById('draw');
    if (canvas.getContext) {
      var ctx = canvas.getContext('2d');
      for (i=0,i<=700,i+=10){
      ctx.beginPath();
      ctx.moveTo(i,700-i);
      ctx.lineTo(700-i,i);
      ctx.stroke();
      }
    } else {
      document.write("Hey idiot, whhich idiot browser you are using? No IE clan here!");
    }
  }
</script> 
</head>
<body onload="draw();"> 
<canvas id="draw" width="700" height="700"></canvas>
</body></html>
Run Code Online (Sandbox Code Playgroud)

谁能告诉我这个简单的代码不起作用的问题是什么?................................

Sim*_*ris 5

因为您的 for 循环使用逗号,所以它需要分号:

for (i=0;i<=700;i+=10){

这也是不行的:

document.write("嘿白痴,你用的是哪个白痴浏览器?这里没有IE一族!");

不要侮辱你的用户!

  • 但当拼写错误时,对一个人智力的侮辱会更加令人愉快。 (3认同)