html - How do I call a JavaScript function every 60 seconds? -


So I'm trying to work on a canvas demo, and I want this class to be from one side to the other But I can not understand how Javascript can be called, which repeats every 60 seconds.

Even so far away from me:

   & Lt; Link href = "/ bms / style.css" rel = "stylesheet" /> & Lt; Style & gt; Body {text-line: center; Background color: # 000000;} canvas {background-color: #ffffff;} & lt; / Style & gt; & Lt; Script type = "text / javascript" & gt; Var x = 50; Var y = 250; Function Updates () {Draw (); X = x + 5; } Function draw () {var canvas = document. GetElementById ('screen1'); If (canvas.getContext) {var ctx = canvas.getContext ('2d'); Ctx.fillStyle = 'RGB (236,138,68)'; Ctx.fillRect (X, Y, 24,24); }} & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body onLoad = "setTimeout (update (), 0);" & Gt; & Lt; Canvas ID = "Screen 1" width = "500" height = "500" & gt; & Lt; / Canvas & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

  & lt ;! DOCTYPE html & gt; & Lt; Html lang = "en" & gt; & Lt; Top & gt; & Lt; Title & gt; Canvas test & lt; / Title & gt; & Lt; Meta charset = "UTF-8" /> & Lt; Link href = "/ bms / style.css" rel = "stylesheet" /> & Lt; Style & gt; Body {text-line: center; Background color: # 000000;} canvas {background-color: #ffffff;} & lt; / Style & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Canvas ID = "Screen 1" width = "500" height = "500" & gt; & Lt; / Canvas & gt; & Lt; Script type = "text / javascript" & gt; Var x = 50; Var y = 250; Function Updates () {Draw (); X = x + 5; } Function draw () {var canvas = document. GetElementById ('screen1'); If (canvas.getContext) {var ctx = canvas.getContext ('2d'); Ctx.fillStyle = 'RGB (236,138,68)'; Ctx.fillRect (X, Y, 24,24); }         }             Updates(); Set interval (update, 60000); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

1000ms = 1 second, 60000 = 60 seconds


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -