尝试实现 excanvas 但出现错误
我正在尝试实现 excanvas,以便我的脚本可以在 IE 以及符合标准的浏览器中运行。我包括 jquery、excanvas 然后是我的脚本。我正在像这样创建画布元素:
data.canvas = $(document.createElement('canvas')).attr('width', data.fontwidth * 80 + 'px').attr('height', data.fontheight * 25 + 'px');
$this.append(data.canvas);
但是当我尝试 ctx = data.canvas[0].getContext('2d'); 我得到一个 Object does not support该行上的此属性或方法错误。此外,我在 excanvas.js 内的第 160 行收到一个
Invalid argument` 错误。
我的完整代码位于此处。工作页面(除了 IE 之外的所有页面)位于此处。我使用的 excanvas 版本位于此处。
更新解决了第二个错误。我必须在调用 init 函数之前附加该元素。
I'm trying to implement excanvas so that my script works in IE as well as standards compliant browsers. I'm including jquery, excanvas then my script. I'm creating the canvas element like so:
data.canvas = $(document.createElement('canvas')).attr('width', data.fontwidth * 80 + 'px').attr('height', data.fontheight * 25 + 'px');
$this.append(data.canvas);
But when I try ctx = data.canvas[0].getContext('2d');
I'm getting an Object doesn't support this property or method' error on that line. Additionally I'm getting an
Invalid argument` error on line 160 inside excanvas.js.
My full code is here. The working (in everything except IE) page is here. The version of excanvas I'm using is here.
update solved the 2nd error. i had to append the element before calling the init function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自文档:
From the docs:
画布宽度属性必须是数字。
不是
canvas width attribute must be number.
not