I am using HTML5 Canvas,javascript. I have made an page with the help of html5 canvas and javascript..But when I run it it gave me this error
("Error=Unable to get the value of the property 'getContext': object is null or undefined")
but it does not terminate the program..the program is running fine with this .
function draw(canvas0) {
var canvas = canvas0;
options = null;
// Canvas good?
if (canvas !== null && canvas.getContext)
}
function initCanvas() {
var canvas1 = document.getElementById('tutorial');
var canvas2 = document.getElementById('tutorial1');
var canvas3 = document.getElementById('tutorial2');
var canvas4 = document.getElementById('tutorial3');
var canvas5 = document.getElementById('tutorial4');
draw(canvas1);
draw(canvas2);
draw(canvas3);
draw(canvas4);
draw(canvas5);
}
this is where i am getting the id and returning these values
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8" />
<title>Speedometer HTML5 Canvas</title>
<script src="script copy.js">
</script>
</head>
<body onload='initCanvas();'>
<canvas id="tutorial" width="440" height="220" style="zoom:50%">
Canvas not available.
</canvas>
<canvas id="tutorial1" width="440" height="220" style="zoom:50%">
Canvas not available.
</canvas>
<canvas id="tutorial2" width="440" height="220" style="zoom:50%">
Canvas not available.
</canvas>
<canvas id="tutorial3" width="440" height="220" style="zoom:50%">
Canvas not available.
</canvas>
<canvas id="tutorial4" width="440" height="220" style="zoom:50%">
Canvas not available.
</canvas>
<form id="drawTemp">
</form>
</div>
</body>
</html>
after seeing the answer given by kennebec if have created change in my code
if (canvas != null && canvas.getContext)
.
After using this line the getContext error is not coming ,But after executing the page that is after drawing the canvas it gives me new error ("Canvas Not Supported By Your Browser").Help me out here.