I've been trying out the HTML5 <canvas> element, and cannot get it to work. here is my code:
<html>
<head>
<script type="text/javascript" >
var canvas=document.getElementById("canvas");
var context=canvas.getContext('2d')
context.fillRect(100,100,300,300);
</script>
</head>
<body>
<canvas width="500" height="500" id="canvas" />
</body>
</html>
The canvas is there (I confirmed this), but nothing is on it. A javascript editor gives me this error:
Uncaught TypeError: Cannot call method 'getContext' of null
Does anyone know why?