Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creat a canvas by javascript #11

Open
zhao-ping opened this issue Jul 3, 2017 · 2 comments
Open

creat a canvas by javascript #11

zhao-ping opened this issue Jul 3, 2017 · 2 comments

Comments

@zhao-ping
Copy link

when I create a canvas by javascript , it show me 'object unsupport“getContext” ' on IE8

my code like that
var canvas = document.createElement("canvas"); var ctx = canvas.getContext("2d");

@ghost
Copy link

ghost commented Sep 11, 2017

If you have created your canvas element dynamically it will not have the getContext method added to the element. To get it working you need to call initElement on the G_vmlCanvasManager object.

var el = document.createElement('canvas');
G_vmlCanvasManager.initElement(el);
var ctx = el.getContext('2d');
Thats it. Now you can use the HTML5 spec for Canvas as your reference.

@liligot
Copy link

liligot commented Sep 18, 2018

Great thanks so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants