开发者

HTML frames interaction & Javascript: Firefox issue

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:

  1. I have two HTML pages: Page-A & Page-B. Page-A contains an iframe element, which its source points to Page-B.
  2. Page-B contain开发者_如何学编程s a JavaScript function: foo. for the sake of this example, this function only pops-up an alert.
  3. 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();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜