views:

279

answers:

2

I'm trying to call a function, test(), of an iframe from the parent document using the code

subframe.test();

subframe refers correctly to the iframe, alert(subframe) returns [object HTMLIFrameElement], and the function runs in both IE7 and opera (9.23), but not firefox (3.0), chrome (3.0) or safari (3.03 beta windows). I assume these browsers support the functionality, so wondering if perhaps I'm using an incorrect call which IE and Opera support anyway, which wouldn't surprise me.

A: 

Is the domain of the parent document's source the same as that of the child iframe's? I believe FireFox requires that they are in order to do something like this.

Wallacoloo
Yes, they're in the same domain.
wyatt
@wyatt - try `subframe.documentElement`
K Prime
subframe.documentElement returns undefined for me. For reference, I solved it in the end using subframe.contentWindow.test();
wyatt
A: 

Thought I should answer for posterity - I solved the problem using subframe.contentWindow.test() .

wyatt