Мне нужна помощь с моей проблемой; похоже, Chrome не любит, чтобы запустить этот код, но на Firefox это работает:Невозможно вызвать метод 'appendChild' от нуля
function createContext(width, height) {
var canvas = document.createElement('canvas');
canvas.id = "1";
canvas.width = width;
canvas.height = height;
document.body.appendChild(canvas);
return canvas.getContext('2d');
}
это хорошо работает в моей хромированной консоли, попробуйте запустить свой код после DOM готов – yoyo
возможно дублировать HTTP://stackoverflow.com/questions/8670530/javascript-error-cannot-call-method-appendchild-of-null http://stackoverflow.com/questions/19086159/uncaught-typeerror-cannot-call-method-appendchild-of- null http://stackoverflow.com/questions/14946428/how-to-fix-uncaught-typeerror-cannot-call-method-appendchild-of-null http: //stackoverflow.c om/questions/9677879/can not-call-method-appendchild-to-null-error-why –