在iFrame中将Javascript上下文设置为iFrame
我有一个带有的页面,在
里面,另一个
弹出窗口。 我要做的是调用
的
设置的函数….我知道,正在进行相同标记的批次。
这就是我在HTML格式中的意思。
//blahblah.html html //blahblahpopup.html html, also where the function is set.
所以,正如您所看到的, 中有一个
。
现在让我们开始做生意吧。 我正在使用这个JS代码将我的JS上下文放到名为’iframe’的第一级
window.frames['iframe'].showAssetPicker();
它的作用是调用第一级的弹出窗口。 但是现在我需要在刚刚调用的弹出窗口内调用一个函数。 (这是另一个
…我不是所有
的原因……)
所以这是我在第二级中调用函数的失败尝试…
window.frames['iframe'].frames['iFrame2'].populateTypePullDown('/getdata/');
我也试过了
window.frames['iframe'].window.frames['iFrame2'].populateTypePullDown('/getdata/');
似乎都没有用。 对此有何帮助? 我使用node-webkit删除安全限制。
谢谢你的帮助,你可以抛出我的方式!
PS Goodness亲切,我在这篇文章中说过太多次了。
问题可能是您在加载资产选择器之前没有等待,因此尚未定义函数populateTypePullDown
。
尝试这样的事情:
$('#iframe') .ready(function() { var $innerIframe = $(this).contents().find('#iFrame2'); console.log($innerIframe, 'ready'); $innerIframe.get(0).contentWindow.populateTypePullDown('/vsg/ipm/SecuredOfferRepository'); }) .get(0).contentWindow.showAssetPicker();
想出答案。 我做的是我进入主 ,并得到
的contentWindow。
$('#iframe').contents().find('#iFrame').get(0).contentWindow.performSearch();