Karl,
nice tip, is there a link to this in the documentation for ready() ?

It will not force users to read the documentation but you can answer
back with a link to the docs.

I see this may pop up frequently for Webkit/Opera users so a small
description will hopefully cut on the number of hits.


Diego


On 2 Feb, 14:20, Karl Swedberg <[email protected]> wrote:
> If the problem you're having is with stylesheet info not being  
> available on ready, the solution is to change the source order in the  
> html: make sure that you reference them in the head before you  
> reference your scripts.
>
> --Karl
>
> ____________
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On Feb 2, 2009, at 6:53 AM, Tom Tom wrote:
>
> > Hello.
> > I discovered some time ago that in browsers based on WebKit, the  
> > ready not working properly. Looking into the code of jQuery 1.3.1 in  
> > binready I noticed it was missing the code. Because it tests only  
> > for IE and mozilla. It does not test for Opera, Safari and Chrome.
> > I analyzed the version 1.2.6 and the bindready code has changed,  
> > result, in opera, safari and chrome, the ready does not work  
> > properly (stylesheets are loaded after the page content)
> > Could you give me an alternative to not put the code of 1.2.6 in  
> > 1.3.1?
>
> > Here is the code I changed. The ready work correctly with these  
> > changes :
>
> > // Figure out what browser is being used
> > jQuery.browser = {
> >     version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ )  
> > || [0,'0'])[1],
> >     safari: /webkit/.test( userAgent ),
> >     opera: /opera/.test( userAgent ),
> >     msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
> >     mozilla: /mozilla/.test( userAgent ) && !/(compatible|
> > webkit)/.test( userAgent ),
> >     language: navigator.language? navigator.language :  
> > navigator.userLanguage,
> >     chrome : /chrome/.test(navigator.userAgent.toLowerCase())
> > };
>
> > function bindReady(){
> > if ( readyBound ) return;
> >         readyBound = true;
>
> >         // Mozilla, Opera (see further below for it) and webkit  
> > nightlies currently support this event
> >         if ( document.addEventListener && !jQuery.browser.opera && !
> > jQuery.browser.safari && !jQuery.browser.chrome)
> >                 // Use the handy event callback
> >                 document.addEventListener( "DOMContentLoaded",  
> > jQuery.ready, false );
>
> >         // If IE is used and is not in a frame
> >         // Continually check to see if the document is ready
> >         if ( jQuery.browser.msie && window == top ) (function(){
> >                 if (jQuery.isReady) return;
> >                 try {
> >                         // If IE is used, use the trick by Diego  
> > Perini
> >                         //http://javascript.nwbox.com/
> > IEContentLoaded/
> >                         document.documentElement.doScroll("left");
> >                 } catch( error ) {
> >                         setTimeout( arguments.callee, 0 );
> >                         return;
> >                 }
> >                 // and execute any waiting functions
> >                 jQuery.ready();
> >         })();
>
> >         if ( jQuery.browser.opera )
> >                 document.addEventListener( "DOMContentLoaded",  
> > function () {
> >                         if (jQuery.isReady) return;
> >                         for (var i = 0; i <  
> > document.styleSheets.length; i++)
> >                                 if  
> > (document.styleSheets[i].disabled) {
>
> > setTimeout( arguments.callee, 0 );
> >                                         return;
> >                                 }
> >                         // and execute any waiting functions
> >                         jQuery.ready();
> >                 }, false);
>
> >         if ( jQuery.browser.safari || jQuery.browser.chrome) {
> >                 var numStyles;
> >                 (function(){
> >                         if (jQuery.isReady) return;
> >                         if ( document.readyState != "loaded" &&  
> > document.readyState != "complete" ) {
> >                                 setTimeout( arguments.callee, 0 );
> >                                 return;
> >                         }
> >                         if ( numStyles === undefined )
> >                                 numStyles = jQuery("style,  
> > link[rel=stylesheet]").length;
> >                         if ( document.styleSheets.length !=  
> > numStyles ) {
> >                                 setTimeout( arguments.callee, 0 );
> >                                 return;
> >                         }
> >                         // and execute any waiting functions
> >                         jQuery.ready();
> >                 })();
> >         }
>
> >         // A fallback to window.onload, that will always work
> >         jQuery.event.add( window, "load", jQuery.ready );
> > }
>
> > Thank you in advance.
>
> > Votre correspondant a choisi Hotmail et profite d'un stockage  
> > quasiment illimité. Créez un compte Hotmail gratuitement !
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to