Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.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
Javascript 从fancybox.open返回值-如何识别fancybox窗口?_Javascript_Iframe_Fancybox_Return_Return Value - Fatal编程技术网

Javascript 从fancybox.open返回值-如何识别fancybox窗口?

Javascript 从fancybox.open返回值-如何识别fancybox窗口?,javascript,iframe,fancybox,return,return-value,Javascript,Iframe,Fancybox,Return,Return Value,在Stackoverflow上,我找到了以下解决方案: 特别是: beforeShow : function(){ x = $('.fancybox-iframe').contents().find('#banner_width1').val(); }, afterClose: function(){ alert("the value of input#banner_width1 is : "+x); // optional } 但是如果我动态打开fancybox呢?像这样: $.fan

在Stackoverflow上,我找到了以下解决方案:

特别是:

beforeShow : function(){
 x = $('.fancybox-iframe').contents().find('#banner_width1').val();
},
afterClose: function(){
 alert("the value of input#banner_width1 is : "+x); // optional
}
但是如果我动态打开fancybox呢?像这样:

$.fancybox({
  href : 'iframe.php', 
  type: 'iframe',
  autoSize: false,
  width: '90%',
  height: '90%',
  beforeClose: function() {
    console.log($(???).contents().find("#retVal").val());
  }
});
<input id="retVal" value="foo">
我应该用什么来替换???具有在iframe.php网站上有如下输入:

$.fancybox({
  href : 'iframe.php', 
  type: 'iframe',
  autoSize: false,
  width: '90%',
  height: '90%',
  beforeClose: function() {
    console.log($(???).contents().find("#retVal").val());
  }
});
<input id="retVal" value="foo">
谢谢各位


m、

你试过什么?更有效的方法是发布您的实验内容和收到的错误,而不是提出开放式问题。您正在阅读fancybox iframe的内容,因此它仍然是相同的选择器x=$”。fancybox iframe“。。。。。