1

getting below error on IE8

canvas.getContext("2d") Unexpected call to method or property access.Error

i have also add

 if (typeof G_vmlCanvasManager != 'undefined') {
                G_vmlCanvasManager.initElement(canvas);
            }

how to run canvas in IE8 with ecanvas.js. also i have check but no luck for me on it.

thanks

Community
  • 1
  • 1
MANISHDAN LANGA
  • 2,227
  • 6
  • 29
  • 43

1 Answers1

2

Firstly, you're sure you've included the file in your markup (as per the documentation):

<head>
<!--[if IE]><script src="PATH_TO_JS_FILE"></script><![endif]-->
</head>

Are you definitely instantiating your "canvas" properly? If you're doing it dynamically then:

var canvas = document.createElement('canvas');
G_vmlCanvasManager.initElement(canvas);
var context = canvas.getContext('2d');

Or if you've added your canvas to the page's markup are you grabbing a reference to it:

var canvas = document.getElementsByTagName("canvas")[0];

Your browser doesn't know what to do with your canvas object, so it looks like it's not instantiated properly.

Paul Aldred-Bann
  • 5,840
  • 4
  • 36
  • 55