当我想要获取画布的上下文时,我遇到了一个问题。 下面是HTML代码:无法获取画布的上下文
<canvas id="thecanvas" width="600" height="300"></canvas>
和JavaScript:
var canvaso = document.getElementById('thecanvas');
if (!canvaso) {
alert('Error: Cannot find the canvas element!');
return;
}
if (!canvaso.getContext) {
alert('Error: Canvas context does not exist!');
return;
}
的 “canvaso” 变量是否正确装入,但它没有对 “canvaso.getContext”:
Uncaught TypeError: Object #<HTMLDivElement> has no method 'getContext'
感谢您的帮助。
你是什么浏览器? – 2012-07-27 20:57:25
http://caniuse.com/#feat=canvas – Joe 2012-07-27 21:02:46
看看您的浏览器是否真的符合html5 http://www.smashcat.org/av/canvas_test/ http://html5test.com – Frobzig 2012-07-27 21:03:07