0

そのフレームの親ページからiframeで関数を実行しようとしています。どちらも同じドメインにあります。
関数は子ページのウィジェットの一部であり、これはページの読み込み時にアクティブ化されます。

function(){apex.jQuery(document).apex_save_before_exit({...});};;

ウィジェット コードの一部:

(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;
   ...

ウィジェットが機能することはわかっています。iframe で試してみると (iframe ではない場合)、期待どおりに機能するからです。

changeDetectedしかし、親ページから関数を呼び出したいです。
注: 私はこれらを firebug コンソールから実行しています!

window.frames['cbox1346667865025'].document.apex_save_before_exit('changeDetected')

収量

TypeError: window.frames.cbox1346667865025.document.apex_save_before_exit is not a function

使用時も同様

$('iframe.cboxIframe')[0].contentWindow.document 
or
$('iframe.cboxIframe').contents()

収量

TypeError: $("iframe.cboxIframe").contents().apex_save_before_exit is not a function

私は何を間違っていますか?それは可能ですか?

4

1 に答える 1

0

iframe のコンテンツが iframe の外側のドメインとは異なるドメインにある場合、これを行うことはできません。

また、おそらく jquery オブジェクトではなく実際の要素が必要なので、代わりに次のようにします。

document.getElementById('myiframe').document.someFunction(arg1, arg2,...);
于 2012-09-03T11:28:00.453 に答える