[Javascript] iframe question

Paul Novitski paul at dandemutande.org
Thu Mar 18 10:31:30 CST 2004


Michael,

Here's what's worked for me.  I'd appreciate any improvements anyone can 
suggest:

- Script in an iframe can refer to elements and functions in the parent 
document using the "parent." prefix, e.g.:

         oObj = parent.document.getElementById(sObjId);
         <tag onClick="parent.DoSomething();">

- Elements within an iframe belong to the iframe's own document object, so 
script in the parent can refer to elements in an iframe like this:

         document.frames(sFrameId).document. ...
e.g.:
         document.frames(sFrameId).document.getElementById(sObjId); 
document.frames(sFrameId).document.body.style.backgroundColor = "blue";

- Therefore, one iframe can refer to elements in a sibling iframe with:

         parent.document.frames(sSiblingFrameId).document. ...

In an application I'm working on now, actions taken in one iframe trigger 
an event in the parent which sets and/or reloads the src of another 
iframe.  So far it's working beautifully -- albeit for this project I don't 
have to worry about cross-browser compatibility -- what a relief!

Paul


At 05:30 AM 3/18/2004, you wrote:
>OK, so I reference the iframe by its name? Where do I put the javascript? 
>in an onSubmit() function perhaps?
>
>Michael
>
>On 18-Mar-04, at 7:01 AM, Håkan Magnusson wrote:
>[cut]
>>On a sidenote; You could also simply do a location.reload(true) on the 
>>document in the iframe. By specifying true as a parameter for reload you 
>>will force the browser to make a new HTTP GET request, (hopefully) not 
>>using the cached version.
>>
>>Regards,
>>H
>>
>>David Lovering wrote:
>>>I would imagine simply setting the iframe's SRC attribute to null, and then
>>>back to its original location.href would accomplish what you ask.  It would
>>>probably not be browser independent, since Mozilla/Netscape clones
>>>historically don't handle iframes well.
>>>-- Dave Lovering
>>>----- Original Message ----- From: "Michael Hanna" <tao at spymac.com>
>>>To: "[JavaScript List]" <javascript at LaTech.edu>
>>>Sent: Thursday, March 18, 2004 4:29 AM
>>>Subject: [Javascript] iframe question
>>>>hi all, I'm new to this list and javascript. I do PHP scripting so I
>>>>have some fundamentals at least.
>>>>
>>>>my question is thus. I have a form to enter Events in an iframe. I want
>>>>to POST to PHP_SELF, so that the new Event appears later on in the
>>>>page/iframe.
>>>>
>>>>see
>>>>
>>>>http://www.siddha.ca/sites/3p94proto/
>>>>
>>>>here's the kicker: how do I also send information to the middle
>>>>iframe(which is a calendar view) to also reflect the change in the DB.
>>>>
>>>>The middle iframe needs to simply reload itself, just in case the event
>>>>appears in the calendar.
>>>>
>>>>Any suggestions?
>>>>Michael
>>>>
>>>>_______________________________________________
>>>>Javascript mailing list
>>>>Javascript at LaTech.edu
>>>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>>>
>>>_______________________________________________
>>>Javascript mailing list
>>>Javascript at LaTech.edu
>>>https://lists.LaTech.edu/mailman/listinfo/javascript
>>_______________________________________________
>>Javascript mailing list
>>Javascript at LaTech.edu
>>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript





More information about the Javascript mailing list