我有一个带有 <iframe>
的页面, 在里面 <iframe>
另一个 <iframe>
弹出一个窗口。我想要做的是调用一个在 <iframe>
中设置的函数的 <iframe>
....我知道,很多相同的标签正在发生。
这是我在 HTML 格式中的意思。
<body>
<iframe src="blahblah.html" name="iframe">
//blahblah.html html
<iframe src="blahblahpopup.html" name="iFrame2">
//blahblahpopup.html html, also where the function is set.
</iframe>
</iframe>
</body>
因此,如您所见,有一个 <iframe>
在<iframe>
.
现在让我们进入正题。我正在使用此 JS 代码将我的 JS 上下文放入第一级 <iframe>
名称为“iframe”
window.frames['iframe'].showAssetPicker();
它所做的是调用第一级内的弹出窗口 <iframe>
.但是现在我需要在刚刚调用的弹出窗口中调用一个函数。 (这是另一个 <iframe>
...我不是所有 <iframe>
的原因...)
所以这是我调用二级定义的函数的失败尝试 <iframe>
...
window.frames['iframe'].frames['iFrame2'].populateTypePullDown('/getdata/');
我也试过
window.frames['iframe'].window.frames['iFrame2'].populateTypePullDown('/getdata/');
似乎都不起作用。有什么帮助吗?我正在使用 node-webkit 删除 <iframe>
安全限制。
感谢您提供的任何帮助!
附言天哪,我说<iframe>
在这篇文章中出现了太多次。
最佳答案
可能的问题是您没有等待 Assets 选择器加载,因此函数 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();
关于javascript - 在 iFrame 中将 Javascript 上下文设置为 iFrame,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30061007/