IE7 excanvas -- $(document).ready() 和 IE7 产生问题
编辑:我已经确定了以下问题的链接,即使用 $(document).ready() 而不是使用主体的老式 onload 属性
问题
在 IE7 中的 canvas/excanvas在您点击重新加载之前不会渲染——我已经多次清除缓存,结果是一致的。
初始页面加载时画布始终为空,并且出现错误“对象不支持此属性或方法”——一条引用 .getcontext() 调用的消息。然而,一旦我点击重新加载,它就会神奇地起作用。总是在重新加载后..它有效。通过任何其他方式到达该页面都不会起作用。初始页面加载时总是出现错误。
“初始页面加载”是指当页面从点击的链接、手动输入地址栏或通过后退/前进按钮加载时。
这是一个复制品: http://www.trevorsimonton.com/canvas_problem/example7.html
请注意,有一个那里有很多额外的 Javascript 来重现这个问题起源的 Drupal 环境。
代码
我正在使用 excanvas r3 -- http://code.google.com/p/explorercanvas/downloads/detail?name=excanvas_r3.zip 和 Drupal 6
编辑:我删除了一堆代码,因为我在网站上有两个地方以完全不同的方式处理画布。我能够在上面的目的地重现问题(http://www.trevorsimonton.com/canvas_problem/example7.html)
问题的根源
有谁知道更多有关excanvas或IE7行为的信息这可能会引发此类问题?除了浏览器的缓存之外,还有什么可能导致页面在“重新加载”命令和其他命令之间加载方式不同?
EDIT: I've identified a link to the below problem to the use of $(document).ready() instead of using the old fashioned onload attribute of the body
The problem
In IE7 the canvas/excanvas does not render until you hit reload -- I've cleared my cache multiple times, and the result is consistent.
The canvas is always empty on initial page load, and an error comes up "object does not support this property or method" -- a message that refers to the .getcontext() call. However, once I hit reload, it magically works. Always after a reload.. it works. never by any other means of reaching the page does it work. There is always an error on initial page load.
By "initial page load" i mean when the page loads from a clicked link, a manual entry to the address bar or via the back/forward buttons.
Here's a reproduction:
http://www.trevorsimonton.com/canvas_problem/example7.html
Note that there's a lot of extra Javascript in there to reproduce the Drupal environment where this problem originated.
The code
I am using excanvas r3 -- http://code.google.com/p/explorercanvas/downloads/detail?name=excanvas_r3.zip and Drupal 6
EDIT: I removed a bunch of the code I had, because I have 2 places on the site where I am handling canvases completely differently. I was able to reproduce the problem at the destination above (http://www.trevorsimonton.com/canvas_problem/example7.html)
The root of the question
Does anyone know more about how excanvas or IE7's behavior that might trigger this kind of issue? What, aside from the browser's cache, could be causing the page to load differently between a "reload" command and anything else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为这是 Drupal 6,所以我使用 Jquery 1.3.2
显然
$(document).ready()
在 excanvas 真正准备好之前触发。尽管大多数浏览器并非如此,但 IE 当然会有所不同。IE7 需要对
getContext()
的所有调用都源自传递到 body 标记的 onready 属性的函数。在 drupal 中执行此操作有点棘手,但我只是将其硬编码到页面模板中。
如果您想要完整的操作方法,请参阅此内容:excanvas 和 JQuery 1.3.2 文档就绪无法相处
Because this is Drupal 6 I'm using Jquery 1.3.2
Apparently
$(document).ready()
fires before excanvas is really ready. Although that's not the case in most browsers, of course IE is going to be different.IE7 needs all calls to
getContext()
to originate from a function passed into the body tag's onready attribute.Do do this in drupal is a little tricky, but I just hard coded it into the page template.
See this if you want the full how-to: excanvas and JQuery 1.3.2 document ready don't get along