Message from discussion
document.ready firing too early within iframe
Received: by 10.100.168.18 with SMTP id q18mr16387ane.1194447169476;
Wed, 07 Nov 2007 06:52:49 -0800 (PST)
Received: by y42g2000hsy.googlegroups.com with HTTP;
Wed, 07 Nov 2007 14:52:48 +0000 (UTC)
X-IP: 212.36.51.131
From: weepy <jonah...@gmail.com>
To: jQuery Development <jquery-dev@googlegroups.com>
Subject: Re: document.ready firing too early within iframe
Date: Wed, 07 Nov 2007 14:52:48 -0000
Message-ID: <1194447168.383637.118430@y42g2000hsy.googlegroups.com>
In-Reply-To: <cbd4eae20711061309w1343c4fch5d7921ff325b5906@mail.gmail.com>
References: <1193155597.738076.68270@v29g2000prd.googlegroups.com>
<1193177742.389655.192340@v29g2000prd.googlegroups.com>
<1193180501.516147.266280@e34g2000pro.googlegroups.com>
<1193185148.611837.154250@e9g2000prf.googlegroups.com>
<1193198439.834098.211950@t8g2000prg.googlegroups.com>
<1193255314.559590.316580@q3g2000prf.googlegroups.com>
<1193271696.746110.177010@e34g2000pro.googlegroups.com>
<1194359127.702729.115610@o3g2000hsb.googlegroups.com>
<1194375095.823440.24400@19g2000hsx.googlegroups.com>
<1194382019.680807.26460@z9g2000hsf.googlegroups.com>
<cbd4eae20711061309w1343c4fch5d7921ff325b5906@mail.gmail.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.8) Gecko/20071022 Ubuntu/7.10 (gutsy) Firefox/2.0.0.8,gzip(gfe),gzip(gfe)
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
I'll give it a go as well - did u use it in the same way as
doScroll ?
On Nov 6, 4:09 pm, "Gabriel Harrison" <nytesh...@gmail.com> wrote:
> I am sure this has been done, but for IE tests of document ready, can we use
> if(document.activeElement)? It seems to work locally but I haven't tried a
> lot of tests. Have we tried it and discarded it for some reason?
>
> *MSDN*http://msdn2.microsoft.com/en-us/library/ms533065.aspx
>
> *Excerpt*
> *Note* For versions of Microsoft Internet Explorer 5 and later, the *
> activeElement* property is not defined until a document is loaded. A value
> of null is given for this property, if it is accessed inline during the
> loading of a document. This property can be accessed in the
> onload<http://msdn2.microsoft.com/en-us/library/ms536942.aspx>event
> handler function.
>
> Gabriel
>
> On Nov 6, 2007 12:46 PM, weepy <jonah...@gmail.com> wrote:
>
>
>
>
>
> > Thanks Diego - I will try this out and see if it works ok for me.
>
> > On Nov 6, 6:51 pm, Diego Perini <diego.per...@gmail.com> wrote:
> > > @weepy,
>
> > > for current SVN the correct one line patch should be:
>
> > > if (d.parentWindow.frameElement && d.readyState == 'loading') {
> > > return;
>
> > > }
>
> > > before the try/catch block. It is different from what written above
> > > since jQuery "ready" function is only passed a document object.
>
> > > This solves the original problem you posed and generally the order
> > > and synchronization of IFRAME loading. It is also fine for developers
> > > who need to attach widgets to IFRAMEs as soon as possible; please
> > > try yo use "insertBefore" instead of "appendChild" for your widgets
> > > where it is possible and attach the widgets directly to the BODY.
>
> > > However be warned that in IFRAMES, this method will not ensure that
> > > all nodes are completely loaded in the DOM, contrary to what the
> > > doScroll() is able to do well in a normal, non framed, window.
>
> > > If the solution remain as is, with the above line included, and merged
> > > in this way I believe this should be strongly advised in the docs.
>
> > > I personally prefer to have a separate solution/method for IFRAMEs,
> > > possibly embedded with the IFRAME creation code, but I understand
> > > there may be other considerations that will negate this; what is clear
> > > is that a normal window is not behaving like an IFRAME window and
> > > that is probably another reason to have a separation between them.
>
> > > Diego
>
> > > On Nov 6, 3:25 pm, weepy <jonah...@gmail.com> wrote:
>
> > > > I'll add this line of code in - see if it makes/breaks it
>
> > > > what is the status of this - is it likely to go into svn, or stay as a
> > > > separate patch ?
>
> > > > On Oct 24, 7:21 pm, Diego Perini <diego.per...@gmail.com> wrote:
>
> > > > > @weepy,
> > > > > I can still break it with a dynamic page in php containing
> > > > > a few "usleep" and "flush" interleaved in some filler text
> > > > > making it longer than 8Kbytes.
>
> > > > > The behavior of the second IEContentLoaded I presented
> > > > > above is exactly the same as in the original jquery-svn.
>
> > > > > The "doScroll()" method does not produce the same
> > > > > results in documents contained in IFRAMES, at least
> > > > > not the same results we get in the topdocument.
> > > > > This was also what David wrote above.
>
> > > > > I believe we need a different helper with iframes...
> > > > > Currently, I have added the following line before the
> > > > > try/catch block in the above code:
>
> > > > > if (w.frameElement && d.readyState == 'loading') { return; }
>
> > > > > Now I am fighting at breaking this...my php test works here.
>
> > > > > Sorry for the overhead of tests, I know how one may feel
> > > > > after digging deep in the "onload" problem.
>
> > > > > The worst problem here is that we are trying to solve
> > > > > very different problems with the same two line of code.
> > > > > Differentiation requires more code and more testing.
>
> > > > > PS: I can show apps using iframes with no problems
> > > > > but I am using the alternative solution described in my
> > > > > 2nd post above (one for each of Moz/FF/IE/Opera).
>
> > > > > Diego
>
> > > > > On Oct 24, 9:48 pm, weepy <jonah...@gmail.com> wrote:
>
> > > > > > Do we think this method is 'adequate' ? I'm not sure what the test
> > > > > > cases are ?
>
> --
> Sincerely,
> Gabriel Harrison
> (if you encounter issues with my gmail account try me at
> nytescha...@yahoo.com)