Mackenzie17
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by Mackenzie17
-
-
Hi I'm a little new to JavaScript and I am trying to make a small program using an HTML5 canvas. However, when the following code is executed:function Prog(){ var self = this; this.init = function() { var d = document; self.canvas = d.getElementById("can"); self.c = self.canvas.getContext("2d");...}var p = new Prog();p.init();The code works in the other major browsers, but in opera, it throws an error saying "cannot convert self.canvas to object" or sometimes just "self.canvas is null"Thanks in advance
Opera Does Not Get Canvas Handle
in JavaScript
Posted · Edited by Mackenzie17
hi Ingolmethanks for replying, I tried replacingself.c = self.canvas.getContext("2d"); withself.c = d.getElementById("can").getContext("2d"); with that code the error console says"Cannot convert 'd.getElementById("can")' to object"the script is deferred so the page should be loaded before the script is executed thanks