How to call iframe's function from this iframe

Posted by Adrian on Stack Overflow See other posts from Stack Overflow or by Adrian
Published on 2010-05-06T11:51:30Z Indexed on 2010/05/06 12:08 UTC
Read the original article Hit count: 343

Filed under:
|
|
|
|

Hi,

I have an iframe created in Javascript with some function f():

var iframe = document.createElement("iframe");
$(iframe).attr({
  width: 0,
  height: 0,
  frameborder: 0,
  src: this.options.url,
  name: id,
  id: id
});

document.body.appendChild(iframe);

iframe.contentWindow.f = function(data) {
 alert("test");
};

Document loaded in this iframe should call function f():

<script ...>f();</script>

And this works perfectly in Firefox but Opera tells, f() is undefined.

Is there any solution?

Adrian.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about iframe