Child Calling Parent Method/ Iframe Reload from child

This is the example, when a child wanna call it's parent.

including A child page of iframe wanna Adjust the IFrame parent Height and width

The trick is simple access your iframe method from parent.yourmethod();

depends on the hierarcy it can be parent.parent.n...

Example:

Child:

function ChildResizeIframe(height) { 
 
try { 
 
parent.parent.ParentResizeIframe(height); 
 
} catch (e) {
 
 }
 
 } 
 
window.onload = function() 
 
{ 
 
ChildResizeIframe(450); 
 
}; 

Parent:

function ParentResizeIframe(height) { 
//do something with iframe, or other element 
}

Share this post: | | | |
Published Wednesday, December 23, 2009 11:00 AM by cipto

Comments

No Comments