关闭Fancybox时返回iFrame而不是父级

时间:2012-03-08 11:48:14

标签: jquery fancybox

我有一个在Fancybox中呈现的iFrame。在iFrame中,我有另一个链接,根据建议的here在父页面上调用Fancybox。一切都按预期工作。在关闭在父页面上使用Fancybox从iFrame中调用的Fancybox时,我将返回到父页面。但是,我希望修改的行为返回到iFrame而不是父页面。

我目前在iFrame中拥有的Fancybox:

jQuery('.container').on('click', 'a.fancybox-large', function(e){
    e.preventDefault();

    parent.jQuery.fancybox({
        href            : this.href,
        padding         : 0,
        closeBtn        : true,
        fitToView       : true,
        helpers         : { overlay: {opacity: 1, css: {'background-color': '#000000'}} }
    });
});

有什么建议吗?

此致 约翰

1 个答案:

答案 0 :(得分:0)

您可以使用iframe方法选择要关注的.focus()内的元素。

例如在iframe中有一个输入字段

<input type="text" class="field" />

已编辑:添加完整脚本。

afterClose选项

添加到您的脚本中
jQuery('.container').on('click', 'a.fancybox-large', function(e){
 e.preventDefault();
 parent.jQuery.fancybox({
  href            : this.href,
  padding         : 0,
  closeBtn        : true,
  fitToView       : true,
  helpers         : { 
   overlay: {
    opacity: 1, 
    css: {'background-color': '#000000'}
   } 
  },
  afterClose: function(){
   jQuery('.input').focus();
  }
 });
}); // on

并且您的重点将放在关闭fancybox后input内的iframe字段

相关问题