Why not to use 'load' event?
var childWin = open("childwindow.html", "my child window",
"left=20,top=20,width=500,height=500,toolbar=1,resizable=0");
childWin.addEventListener("load", function() {
var elem = childWin.document.getElementById("myelement");
console.log(elem);
}, true);
Honza
On Aug 20, 11:07 am, M Gozler <[email protected]> wrote:
> On Aug 19, 8:08 pm, Jan Odvarko <[email protected]> wrote:
>
> > The document is loaded asynchronously so, the body is not yet there if
> > you access it just after open.
> > Honza
>
> Thanks.
>
> Is there a well-known cross-browser looping test condition that will
> test when the real document content is loaded?
>
> The use of:
>
> while (typeof(window.document.body) == "undefined" ||
> window.document.body == null)
> ;
>
> was of no value. When it breaks on an error because it could not find
> the 'id' attribute of the element it should find, the following is
> true of the window's document properties:
>
> *1. document.URL = "about: blank" // also document.documentURI
> property
> *2. document.baseURI = "chrome://browser/content/browser.xul"
> 3. document.doman = "localhost"
> 4. document.location = "http://localhost/childDocument.html"
> 5. document.body.firstChild = null // also lastChild
> 6. document.body.innerHTML = ""
>
> These are all reported by FB.
>
> The asterisked (*) properties are entirely unexpected, given property
> 4, which actually what it should be. Properties 5 and 6 are not
> wanted either. So why are some properties what they are expected, and
> others are not?
>
>
>
> > On Thursday, August 19, 2010, M Gozler <[email protected]> wrote:
> > > My Javascript opens a child window with URL "childDocument.html".
>
> > > It then attempts to reference the document object.
>
> > > Thus the script is
>
> > > childWin = open("childDocument.html", ...);
> > > childWinDocument = childWin.document;
>
> > > Now if I use FB to break execution just after opening the window, and
> > > step through it, I get the proper reference to the document object. I
> > > can get the 'body' property of document and look for a specific DOM
> > > element by an 'id' attribute I am looking for.
>
> > > But if I don't break with FB, and let script execution proceed at its
> > > normal speed, what happens is that I get a 'null' on finding the DOM
> > > element, because what happens is that URL is not "childDocument.html"
> > > but instead "about:blank" and the baseURI value under the document
> > > object is not "http://localhost/.../childDocument.html" but instead
> > > "chrome://browser/content/browers.xul"
>
> > > Is there an explanation for this?
>
>
--
You received this message because you are subscribed to the Google Groups
"Firebug" 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/firebug?hl=en.