[Javascript] bubble up event
Paul Novitski
paul at novitskisoftware.com
Wed Jun 2 11:49:33 CDT 2004
At 08:23 AM 6/2/2004, Paul Cowan wrote:
>I have an .aspx page which has vertical and horizontal navigation. This
>page has an iFrame which is really the main content frame. How can I
>raise onkeydown events from the iFrame back up to the parent page??
At 08:36 AM 6/2/2004, Chris T wrote:
>In your iFrame, you could have something like:
>
>document.body.onclick = parent.functionName
I've gotten into the habit of using window.top, which points to the top
parent window in the DOM hierarchy no matter how many levels up that might
be. If you're writing modular code that needs to refer to the top parent
regardless of context, you might consider window.top.
Here are two ways that a script running in a child iframe or window can run
an event-related function in the parent window:
parent:
<a id="ParentLink" onclick="ParentBusiness()" ...>
child:
1) either trigger the object's event:
var oObj = window.top.document.getElementById("ParentLink")
oObj.click()
2) or call the function:
window.top.ParentBusiness()
The child has to know either the name of the object or the name of the
function.
(I don't know if there's a "keypress" equivalent of the click()
method. Anyone?)
Paul
More information about the Javascript
mailing list