Canvas Resize problem ?

Hi Kirupa ,
I having trouble with ‘resizecanvas’.
I am using quick.js .
So far , the only way I can get canvas to resize correctly is by ‘location.reload();’ .

I tried the following code from your article:

What happens below is that the canvas size is correct ,
but instead of aligned in center , it displays on screen left .
Is there a different approach I can use ?


@ line 250 ( ) :

window.addEventListener('resize', resizeCanvas, false);
function resizeCanvas () {
var myCanvas = document.getElementById('canvas');
// canvasDiv = canvasDiv.align = 'center';
// myCanvas.width = document.documentElement.innerWidth;  // .inner* = Black Screen
 myCanvas.width =  document.documentElement.clientWidth;   //  .client* = bad canvas align
 myCanvas.height = document.documentElement.clientHeight;   //  .client* = bad canvas align
// myCanvas.height =  document.documentElement.innerHeight; // .inner* = Black Screen
}	//

Hi, vmars!
Did you fix the problem? From looking at this link (, it seems centered on the screen :slightly_smiling:


Thanks Kirupa ,
I tried both IE and Chrome .
This one works fine:

This one starts off ok , but hit the maximize-btn and restore-down
back and forth a few times ; Each subsequent time is is gameCanvas get skewed to Left .

Cheers vmars