javascript function not defined

bh7126

New Member
I set the function called "drawEverything()" to run onload, however the function doesn't run and I get a bug in Firebug saying "drawEverything is not defined"?? Thing is, I did define it!I googled the problem and most of the time it was due to some kind of syntax error, but I've looked all over it and can't find any syntax errors.My code is as follows:\[code\]<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Test</title><link rel=stylesheet href="http://stackoverflow.com/questions/13787110/style.css" type="text/css"></head><script type="text/javascript">var new_x = 110;var new_y = 150;function drawEverything(){ var temp_x = new_x; var temp_y = new_y; var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); for (int i = 0; i < 5; i++){ ctx.beginPath(); ctx.arc(temp_x,temp_y,20,0,2*Math.PI); ctx.stroke(); if ((i < 3) || (i == 4)){ temp_x += 40; } else if (i == 3){ temp_y += 20; temp_x -= 60; } }}</script><body onload = "drawEverything()"><h1>Interactive Olympic Rings</h1><div id="container"><canvas id="myCanvas" width="300" height="300"></canvas></div></body></html>\[/code\]Any help would be appreciated, thanks!
 
Back
Top