gpt4 book ai didi

javascript - FancyBox - 单击按钮时重新加载父页面

转载 作者:行者123 更新时间:2023-11-28 08:32:03 31 4
gpt4 key购买 nike

我正在使用fancybox在另一个页面(parent.htm)中显示一个页面(例如child.htm)。

我知道如何自动 reload the parent page after closing the iFrame :

$(".fancybox").fancybox({
afterClose : function() {
location.reload();
return;
}
});

但是,我的要求更具体。我需要关闭 iframe,然后仅当用户单击按钮时重新加载父页面 (parent.htm)(例如:单击 child.htm 中的“确定”按钮)。

我遇到的代码片段的问题是,即使我单击关闭图标或单击框架外的任何位置,父页面也会重新加载。这是我想要限制的事情。我的议程是仅在单击按钮时刷新页面。

最佳答案

我会尝试这样的事情:

  $('.fancybox').fancybox({
href : 'child.html',
type : 'iframe',
afterShow: function(){
$('.fancybox-iframe').contents().find('#button').click(function(){
// do something
...

// reload parent window and close fancybox
window.parent.location.reload();
window.parent.$.fancybox.close();
});
}
});

关于javascript - FancyBox - 单击按钮时重新加载父页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21732545/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com