[Javascript] Poorly documented facet of cross-frame execution
Rodney Myers
rodney at aflyingstart.net
Wed Apr 9 06:07:57 CDT 2003
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>
More information about the Javascript
mailing list