Javascript 从fancybox.open返回值-如何识别fancybox窗口?
在Stackoverflow上,我找到了以下解决方案: 特别是: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
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“。。。。。