What is correct javascript function to get a iframe
<p>When I developed a FB application, I tried to get the canvas used javascript like below:</p>

<h3>Work</h3>

<pre><code>document.getElementsByTagName('iframe')[1].id
//Output: iframe_canvas
</code></pre>

<h3>Not Work</h3>

<pre><code>window.frames[1].id
//Output: undefined
</code></pre>

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

<blockquote>
  <p><a href="http://stackoverflow.com/questions/251420/invoking-javascript-in-iframe-from-parent-page#251453">Invoking javascript in iframe from parent page</a></p>
</blockquote>

<p>But, I really don't understand <code>why</code>:</p>

<blockquote>
  <p>You can't use "window.frames" if your IFRAME was created programmatically, only if it is declared in the HTML page source. Src <a href="http://stackoverflow.com/users/18771/tomalak">@Tomalak</a>'s comment</p>
</blockquote>
