html5 - Handling canvas.drawImage errors when image.src is unavailable -
what efficient , proper way handle calling drawimage on canvas context when image's src url unavailable. example:
myimage.src = "imagedoesnotexist"; canvasctx.drawimage(myimage,0,0); // 0x80004005 - javascript runtime error: unspecified error.
thanks!
in addition image.onload
there image.onerror
these occasions
var img = new image(); img.onload = function(){ context.drawimage(img,0,0); }; img.onerror = function(){ alert("oops, bad stuff happened while loading image."); }; img.src = "imagedoesnotexist";
Comments
Post a Comment