Call function inside iframe
<p>im trying to do something here. I have a document which I set an array. Then, jquery takes this array and appends an iframe for each value:</p>

<pre><code>&lt;script&gt;
  var containers = new Array("test1", "test2");
&lt;/script&gt;
</code></pre>

<p>This results is 2 iframes, identified by id with his name. Ok. perfect, working. Then, inside of each iframe, it calls a document. Inside this document, I have a function called <code>play()</code>. </p>

<p>I am testing <code>play()</code> by returning an alert. Whenever I click on a button, it works:</p>

<pre><code>$("#viewport .next").click(function(){
    document.getElementById(containers[current]).contentWindow.play();
});
</code></pre>

<p>This works. Perfectly. But I it put this function to trigger on document ready, it doesnt works.</p>

<pre><code>$(function() {
    document.getElementById(containers[current]).contentWindow.play();
});
</code></pre>

<p>It returns to me:</p>

<p><code>Uncaught TypeError: Object [object Window] has no method 'play'</code></p>

<p>Whats am I doing wrong guys?
Thanks!</p>

<p><strong>EDIT</strong></p>

<p>Tried to apply onload on iframe. Didnt work.</p>

<pre><code>var initialFrame = containers[qual];

initialFrame.onload = function() {
    document.getElementById(initialFrame).contentWindow.play();
};
</code></pre>

<p><strong>EDIT2</strong></p>

<p>For some reason, it started working. Thanks!</p>
