Forum Moderators: open

Message Too Old, No Replies

Call function from iframe

         

Lagon

12:59 pm on Aug 12, 2008 (gmt 0)

10+ Year Member



I want call a function from IFRAME that execute in parent window.

LIKE:


onclick="window.parent.document.myFunction('test');"

but this not work.

Fotiman

2:15 pm on Aug 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld! Global functions in the parent window reside in the window object, not in the document object. Assuming your function is defined prior to your iframe, either of these should work:

window.parent.myFunction('test');
or
top.myFunction('test');

[edited by: Fotiman at 2:16 pm (utc) on Aug. 14, 2008]