I tried the following code but firefox4 does not display me anything..
<script type="text/javascript">
var canvas = document.getElementById('canvas1');
var context = canvas.getContext('2d');
context.strokeStyle = '#990000';
context.strokeRect(20,30,100,50);
alert(context);
</script>
<canvas id="canvas1" width="200px" height="200px">Your browser does not support canvas </canvas>
This code is inside body tag.
you have to understand the order in which the file is executed by the browser.
Here is the way in which the browser is reading this code:
canvas1nothing.getContext('2d');alert(nothing)So to make it visible you just have to edit your code like this:-
NOTE: When using Javascript there is no need to mention it in HTML5.