This is a code snippet from a HTML file:
var canvas = document.getElementById("main-canvas");
var ctx;
if (canvas.getContext){
canvas.getContext('2d');
}
I use this HTML file in a XUL file by means of the following lines:
<vbox id="startbox" flex="1">
<iframe name="centralpane" width="150" flex="1" src="file://x/
xxxxxxxxx/xxxxxx.html"/>
</vbox>
This XUL code works in Firefox. But it fails in a standalone XULRunner
application. The stops at the 'canvas.getContext('2d')' method. Is
there a workaround for this to get the thing working? Does someone has
any tips to solve this problem?
Thank you for your time,
Wouter
Try to add ' type="content-primary"' to <iframe> attributes or try to
use <browser> instead.
--
Sergey Yanovich
Hello,
First of all. Thank you for your reply.
I've tried the two things you suggested but it still failed to work. I
think the problem is the javascript method '.getContext('2d')' (and
not the XUL code ) which doesn't do anything in the standalone
XULRunner application. A check on what this method returned gave
nothing (not even a 'null')! Could this be due to the version of
XULRunner (1.8)? My Firefox version is 2.0.0.6 and this works fine.
Thank you for your help and time!
Wouter
Have you checked what the error you're getting is (use the -jsconsole
flag to start your app)? That probably explains something. :-)
~ Gijs
Did you compile XULRunner yourself (--disable-canvas???)?
--
Michael Vincent van Rantwijk
- MultiZilla Project Team Lead
- XUL Boot Camp Staff member (ActiveState Training Partner)
- iPhone Application Developer
Hello Gijs,
Thanks for your reply.
I've tried to debug the application with the command: xulrunner
application.ini -jconsole. (and set
pref("javascript.options.showInConsole",true)). Then I looked into the
Javascript Error console. This gave no error. (or I'm I doing
something wrong here?)
Do you have other suggestions?
Thank you,
Wouter
Hello Michael,
Thank you for your reply.
I didn't compile XULRunner for myself. But got it from
http://developer.mozilla.org/en/docs/XULRunner.
(I'm using a Windows machine)
Do you have any other ideas?
Thank you,
Wouter
Hello,
@Gijs:
I managed to debug something: I get teh following error when I try to
execute the line canvas.getContext('2d');
[Exception..."Component returned failure code: 0x80070057
(NS_ERROR_ILLEGAL_VALUE)
[nsIDOMHTMLCanvasElement.getCOntext]" nsresult: "0x80070057
(NS_ERROR_ILLEGAL_VALUE)"
location: "JS frame::file:///C:/xxxxxxxxxxxx/
test.html::init::line15"data:no]
It seems like the function 'getContext' can't find any data? Does
anybody know how to solve this?
Thank you,
Wouter
Hello,
After some 'googling', I came up with the following useful link:
http://canvex.lazyilluminati.com/tests/tests/spec.html#testrefs.context.empty
This is exactly the error I seem to get. Does anyone know a solution
for this?
Thank you,
Wouter