Exception when using canvas (0x80040111 NS_ERROR_NOT_AVAILABLE)

2

I'm having some trouble writing a JavaScript paint tool. It's a unit test and in the future will be used as a component for a larger project I'm working on. It runs in a canvas but when I try to run it, I get this error message:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage]"  nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame :: http://rasmvillage/canvasapp/js/lib.js :: <TOP_LEVEL> :: line 52"  data: no]

I'm using the jquery library

The HTML is nothing special. Just a div#container with a canvas#imageID and canvas#boardID inside of it. Can someone help me figure out what's wrong? Thanks.

javascript
canvas
asked on Stack Overflow Jul 16, 2011 by Ryan • edited Jul 22, 2011 by Ryan

1 Answer

2

As indicated on canvas drawImage doesn't draw images the first time, make sure you don't operate on images until the images onload has fired. More advice on Image onload for static images, including a jQuery plugin that may help.

answered on Stack Overflow Jul 16, 2011 by Ray Toal • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0