javascript - HTML page not displaying the image -


i have following javascript file:

var canvas = document.getelementbyid('canvas'), context = canvas.getcontext('2d'), image = new image(); image.src = 'abc.jpg'; image.onload = function(){     var cols = image.width;     var rows = image.width;     canvas.width = cols;     canvas.height = rows;     context.drawimage(image, 0, 0, image.width, image.height); }; 

the html file looks follows:

<html> <head>     <title>chapter1</title>     <script src="matrix.js">     </script> </head> <body> <canvas id="canvas"></canvas>    </body> </html> 

but, when try view html page, don't see image, provided files including image in same directory.

what doing wrong?

thanks.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -