Execute a widget function in an iframe
<p>I'm trying to execute a function in an iframe from the parent page of that frame. Both are on the same domain.<br>
The function is part of a widget on the child page, and this is activated on page load.</p>

<pre><code>function(){apex.jQuery(document).apex_save_before_exit({...});};;
</code></pre>

<p>A piece of the widget code:</p>

<pre><code>(function($){
$.widget('ui.apex_save_before_exit', {
   options: {
      saveMessage: null,
      noWarningSelector: null,
      disableTime: null,
      ignoreChangeSelector: null
   },
   values: {
      itemChanged: false,
      promptUser: true,
      forcePrompt: false,
      debug: $('#pdebug').length !== 0
   },
   _create: function() {      
   ...
   },
   ...,
   changeDetected: function() {
      var uiw = this;
      var somethingChanged;
   ...
</code></pre>

<p>I know the widget works because when i try it in the iframe (and when not in the iframe), it works as i'd expect.</p>

<p>But i'd like to call the <code>changeDetected</code> function from the parent page.<br>
Note: i'm running these from the firebug console!</p>

<pre><code>window.frames['cbox1346667865025'].document.apex_save_before_exit('changeDetected')
</code></pre>

<p>Yields </p>

<pre><code>TypeError: window.frames.cbox1346667865025.document.apex_save_before_exit is not a function
</code></pre>

<p>Same when using</p>

<pre><code>$('iframe.cboxIframe')[0].contentWindow.document 
or
$('iframe.cboxIframe').contents()
</code></pre>

<p>Yields</p>

<pre><code>TypeError: $("iframe.cboxIframe").contents().apex_save_before_exit is not a function
</code></pre>

<p>What am i doing wrong? Is it even possible?</p>
