开发者

jQuery later than window load

I am using Cufon.replace to font replace some text on the site. Currently in IE8 standards mode when this is run outside a $(document).ready it is only happening ~50% of the time the rest of the time the DOM changes have occurred (viewing with IE8 built in dev toolbar) but no text is displayed.

Disabling the replace, and applying it manually through the console updates all the text correctly. Wrapping it in $(document).ready stops it from ever occurring - no DOM modifications (as far as I can tell from dev toolbar). However I cannot reapply manually from the console - so it may be lying to me.

Wrapping it in $(window).开发者_开发问答load seems to have the same effect as $(document).ready

Please note this only effects ie8 "Standards mode". It works fine in Firefox and IE7.

Any thoughts?


I've experienced this before... I would wrap it in anonymous function and you can also use a simple setTimeout to delay it as well (may not be needed).

(function( $ ){ 
   // Your Cufon.replace()
   Cufon.replace('h1', { fontFamily: 'stack-overflow', hover: true });
   Cufon.now();

   // OPTIONAL - Delay by 150ms (you can experiment with this value)
   setTimeout(function(){ Cufon.refresh(); }, 150); 

})( jQuery );
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜