开发者

IE7 excanvas -- $(document).ready() and IE7 creates problem

开发者 https://www.devze.com 2023-03-18 09:48 出处:网络
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

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 tha开发者_运维技巧t 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消