gpt4 book ai didi

javascript - 提交后如何关闭 fancybox iframe

转载 作者:行者123 更新时间:2023-11-28 11:28:06 26 4
gpt4 key购买 nike

当 siteB 上的用户单击提交时,我在 siteB 上有一个 iframe,其中有一个来自 siteA 的 iframe

<input type="submit" value="Save url" name="commit" method="post" id="url_submit">

我需要关闭灯箱

我尝试添加

$('#url_submit').click(function(){
$.fn.fancybox.close();
});

两个网站都没有,我有点困惑

最佳答案

首先,siteA 和 siteB 是否在同一个域下?如果是这样,您可以尝试

window.parent.jQuery.fn.fancybox.close();

但如果不是,您必须创建一个回调 url 来关闭您的 fancybox,并且在提交表单时重定向到此 url。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function () {
window.parent.jQuery.fn.fancybox.close();
});
</script>
</body>
</html>

关于javascript - 提交后如何关闭 fancybox iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4081087/

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