I am trying to load a bitmap into the canvas following the example here.
Here is my code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>HTML 5 Reports</title>
<script type="text/javascript">
function draw() {
var ctx = document.getElementById('canvas').getContext('2d');
var img = new Image();
img.onload = function(){
ctx.drawImage(img,0,0);
ctx.beginPath();
ctx.moveTo(30,96);
ctx.lineTo(70,66);
ctx.lineTo(103,76);
ctx.lineTo(170,15);
ctx.stroke(); }
img.src = 'worldmap1.bmp';
}
</script>
</head>
<body onload="draw()">
<canvas id="graph"></canvas>
</body>
</html>
Nothing is drawn in the browser when I view the page. No Errors Given. Please tell me what I am doing wrong. Thanks!