Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iFrame中将Javascript上下文设置为iFrame_Javascript_Jquery_Html_Iframe_Nw.js - Fatal编程技术网

在iFrame中将Javascript上下文设置为iFrame

在iFrame中将Javascript上下文设置为iFrame,javascript,jquery,html,iframe,nw.js,Javascript,Jquery,Html,Iframe,Nw.js,我有一个页面,上面有一个,在这个页面内,另一个作为窗口弹出。我想做的是调用在的中设置的函数。。。。我知道,有很多相同的标签 以下是我在HTML格式中的意思 <body> <iframe src="blahblah.html" name="iframe"> //blahblah.html html <iframe src="blahblahpopup.html" name="iFrame2"> //blahblahpopup.html html,

我有一个页面,上面有一个
,在这个
页面内,另一个
作为窗口弹出。我想做的是调用在
中设置的函数。。。。我知道,有很多相同的标签

以下是我在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>
它所做的是调用第一级
中的弹出窗口。但是现在我需要在刚才调用的弹出窗口中调用一个函数。(这是另一个
…我不是所有
的原因…)

下面是我调用第二级
中定义的函数的失败尝试

window.frames['iframe'].frames['iFrame2'].populateTypePullDown('/getdata/');
我也试过了

window.frames['iframe'].window.frames['iFrame2'].populateTypePullDown('/getdata/');
两者似乎都不起作用。有什么帮助吗?我正在使用node webkit删除
安全限制

谢谢你的帮助,你可以帮我


另外,天哪,我在这篇文章中说了太多次了。

问题可能是,在加载资产选择器之前,您没有等待,因此尚未定义函数
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();

找到了答案。我所做的是进入主
,并在里面获得
的内容窗口

$('#iframe').contents().find('#iFrame').get(0).contentWindow.performSearch();

您是否尝试过改用
window.frames['iframe'].contentWindow
?浏览器控制台中是否有错误?它表示未定义该函数。这意味着我没有进入正确的语境。。听起来是个不错的答案,但我只是用你从另一个问题中的答案猜出来的。:)很高兴你自己解决了你介意我问你最后一件事吗?如何在iframe的上下文中运行脚本?比如,不只是调用函数,你可以插入
script
标记并设置
src
属性,如果这是你想要的<代码>$innerIframe.contents().find('body').append($('').attr(src,'js/myscript.js'))
$('#iframe').contents().find('#iFrame').get(0).contentWindow.performSearch();