[Javascript] Poorly documented facet of cross-frame execution

David T. Lovering dlovering at gazos.com
Wed Apr 9 08:01:31 CDT 2003


Actually, nothing -- you've done it correctly for instances where the routine you are invoking is defined 
in the header block.  Since (by canon) this is where external JavaScript routines should live, all is well.
This is the way I do it myself.

-- Dave Lovering

Rodney Myers wrote:
> 
> David,
> 
> What, in the circumstances you describe, is wrong with
> 
> parent.frameA.foobar();
> or
> parent.frames["frameA"].foobar();
> 
> ?
> 
> Since this is what I now write, and it works, I am very interested, and
> I have no doubt you have a cogent reason.
> If necessary I will change all my code, always willing to learn
> something I did not know.
> 
> Rodney
> 
> David T. Lovering wrote:
> 
> >A number of folks have been alluding to coding structures that require invoking routines across frames (parent/child, child/parent, peer/peer), including IFRAMEs.  One of the elements that seems to be missing from the standard documentation and the
> >JavaScript/JScript RFC's (including the W3C state model) is the fact that when invoking JavaScript one must consider the placement within the target frame as to how one addresses it.
> >
> >For example, if we have two peer frames (frameA and frameB), each containing mycode1.html and mycode2.html respectively, and it is intended that mycode2.html invoke a JavaScript routine 'foobar()' which exists in a <script
> >language='JavaScript'>...</script> block in the header of mycode1.html, the following will NOT work:
> >
> >  parent.document.frames["frameA"].document.foobar();
> >
> >The reason is that the 'document' object in frameA's code module doesn't REALLY begin until it hits the <body> tag.  The correct procedure is therefore
> >
> >  parent.document.frames["frameA"].foobar();
> >
> >
> >
> <snip>
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript


More information about the Javascript mailing list