JQuery later loading windows

I use Cufon.replaceto replace the font on the site. Currently in IE8 standards mode when this runs outside of $ (the document). Already this happens only in 50% of cases when the rest of the time DOM changes have occurred (browsing with IE8, built into the dev toolbar), but no text is displayed.

Disabling the replacement and applying it manually through the console automatically updates the text. Wrapping it in $(document).readyprevents it from ever happening - no DOM changes (as far as I can tell from the dev toolbar). However, I cannot reuse the console manually, so it can harm me.

The wrapper $(window).loadseems to have the same effect as$(document).ready

Please note that these are just the effects of ie8 "Standards Mode". It works fine in Firefox and IE7.

Any thoughts?

+5
source share
1 answer

I had experienced this before ... I would have wrapped it with an anonymous function, and you can also use a simple setTimeout to delay it (it may not be necessary).

(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 );
+1
source

All Articles