this issue is kinda strange, and happens only in Firefox (v. 3.6.6 but also in older versions of 3.6). The best way to explain it is to describe the scenario, so.. here it is:
- I have two HTML pages: Page-A & Page-B. Page-A contains an iframe element, which its source points to Page-B.
- Page-B contain开发者_如何学编程s a JavaScript function:
foo
. for the sake of this example, this function only pops-up an alert. - when Page-A is loaded for the first time, i'm able to get the iframe and execute the
JavaScript function like this:
window.frames["frameName"].foo();
Until now looks normal. but, when I dynamically remove the iframe from Page-A, and then dynamically adds it to the page, this is what happens:
** i can get the instance of iframe: window.frames["frameName"]
** when i try to execute the foo() function, i get an error that it is undefined.
This issue happens ONLY in Firefox. Testes in: IE 7/8, Chrome & Safari - works fine.
Any idea why this is happening? Any idea how to work this out?
Try accessing it using window.frames["frameName"].contentWindow.foo();
精彩评论