I have a web application using two canvases. Today I noticed that one of those canvases won’t be displayed properly in IE9. Unlike the one which is displayed correctly, the second canvas’ size params are not set by a default value, but using the dimensions of an ImageElement which should be loaded before the main application starts.
But altough all of this works properly in Chrome and Firefox, the style params of the canvas remain at 0px.
This is the Code I use to setup the canvas:
tableImage = IMAGES.get(imageName);
simulatorScreen = Canvas.createIfSupported();
simulatorScreen.setPixelSize(tableImage.getWidth(),tableImage.getHeight());
simulatorScreen.setCoordinateSpaceWidth(tableImage.getWidth());
simulatorScreen.setCoordinateSpaceHeight(tableImage.getHeight());
IMAGES is a Map created by my image loader filled with ImageElements, the key is a string.
I found out what the problem was. While Firefox and Chrome supported the storage of the image elements in a seperate variable, IE seems to require the elements to be explicitly stored inside the DOM to have access to its dimension properties. It works properly now.