2

When I developed a FB application, I tried to get the canvas used javascript like below:

Work

document.getElementsByTagName('iframe')[1].id
//Output: iframe_canvas

Not Work

window.frames[1].id
//Output: undefined

I don't know why, after that I looked for the answers on SO, I found the answer and comment for my issue.

Invoking JavaScript code in an iframe from the parent page

But, I really don't understand why:

You can't use "window.frames" if your IFRAME was created programmatically, only if it is declared in the HTML page source. Src @Tomalak's comment

Community
  • 1
  • 1
vietean
  • 2,975
  • 9
  • 40
  • 65

1 Answers1

2

Because browsers have implemented this in such a way. Things like window.frames were never a part of any standard. This is one of the reasons why they are inconsistent and poor sometimes.

bjornd
  • 22,397
  • 4
  • 57
  • 73