oneofakind
oneofakind

Reputation: 562

Calling Functions inside iframe

I am trying to call a function inside an iFrame. Everythings fine with the code below when I'm using Firefox but if I use IE(8) it does not work:

 document.getElementById("iframe").contentWindow.myFunction();

From the parent, I wanted to call the function inside the iFrame. How do I let it work in IE?

Thanks

Upvotes: 2

Views: 1388

Answers (2)

oneofakind
oneofakind

Reputation: 562

I got it to work across all browsers with this code below:

window.frames['iframeid'].window.myFunction();

Upvotes: 0

Rob Sedgwick
Rob Sedgwick

Reputation: 5226

try

var _frame = document.getElementById("iframe");
var contentWin = _frame.contentWindow || _frame.contentDocument;

Upvotes: 1

Related Questions