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
Post a Comment