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从父页面调用该函数。
注意:我正在从萤火虫控制台运行这些!

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 回答