在iFrame中将Javascript上下文设置为iFrame [英] Setting Javascript Context to iFrame in an iFrame

查看:455
本文介绍了在iFrame中将Javascript上下文设置为iFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个< iframe> 的页面,并且在< iframe> 其他< iframe> 弹出窗口。我要做的是调用函数taht设置在< iframe> < iframe> ....我知道,很多相同的标签都在继续。

I have a page with an <iframe>, and inside that <iframe> another <iframe> pops up as a window. What I'm trying to do is call a function taht is set in the <iframe>'s <iframe>.... I know, lot's of the same tag going on.

这就是我在HTML格式中的意思。

Here's what I mean in HTML format.

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

So, as you can see, there is an <iframe> in an <iframe>.

现在让我们开始营业。我正在使用这个JS代码将我的JS上下文放到第一级< iframe> ,名称为'iframe'

Now lets get down to business. I'm using this JS code to get my JS context into the first level <iframe> with the name 'iframe'

window.frames['iframe'].showAssetPicker();

它的作用是调用第一级中的弹出窗口<的iframe> 。但是现在我需要在刚刚调用的弹出窗口内调用一个函数。 (这是另一个< iframe> ...我不是所有< iframe> 's ...)

What that does is it calls the popup inside the first-level <iframe>. But now I need to call a function inside of the popup that was just called. (which is yet another <iframe>... I'm not the cause of all the <iframe>'s...)

所以这是我尝试调用第二级< iframe> ...

So here's my failed attempt of calling a function defined in the second-level <iframe>...

window.frames['iframe'].frames['iFrame2'].populateTypePullDown('/vsg/ipm/SecuredOfferRepository');

我也试过

window.frames['iframe'].window.frames['iFrame2'].populateTypePullDown('/vsg/ipm/SecuredOfferRepository');

两者似乎都不起作用。对此有何帮助?我使用node-webkit删除< iframe> 安全限制。

Neither seem to work. Any help with this? I am using node-webkit to remove <iframe> security restrictions.

感谢您提供任何帮助,我们可以抛弃我的方式!

Thanks for any help you can throw my way!

P.S。善良,我在这篇文章中说过< iframe> 太多次了。

P.S. Goodness gracious, I said <iframe> far too many times in this post.

推荐答案

问题可能是您在资产选择器加载之前没有等待,因此尚未定义函数 populateTypePullDown

Probably the issue is that you don't wait before the Asset Picker is loaded and therefore the function populateTypePullDown is not yet defined.

尝试这样的事情:

$('#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();

这篇关于在iFrame中将Javascript上下文设置为iFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆