var pos_y = canvas.height; - such a record is not valid (the entire canvas becomes clean at once). When trying to set height via document.getElementById too.

At the same time, canvas methods accept canvas.height . Why code validity negates even something as innocuous as var h = document.getElementById('drawingCanvas').clientHeight;

 var canvas; var context; window.onload = function() { canvas = document.getElementById("drawingCanvas"); context = canvas.getContext("2d"); setTimeout("drawFrame()", 300); } var pos_y = 200; // не принимает canvas.height function drawFrame(){ context.clearRect(0, 0, canvas.width, canvas.height); context.fillStyle = 'yellow'; context.strokeStyle = 'yellow' context.fill(); context.beginPath(); context.arc(canvas.width/2, pos_y, 30, 0,Math.PI*2, true); context.stroke(); pos_y-=1; setTimeout("drawFrame()", 300); } 

    1 answer 1

      var canvas; var context; var pos_y; window.onload = function() { canvas = document.getElementById("drawingCanvas"); pos_y = canvas.height; context = canvas.getContext("2d"); setTimeout("drawFrame()", 300); }