gpt4 book ai didi

javascript - 从 iframe 内部关闭 Bootstrap 模式

转载 作者:IT王子 更新时间:2023-10-29 03:16:36 26 4
gpt4 key购买 nike

打开带有 iframe 的 Twitter Bootstrap Modal 的页面:

<div id="iframeModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="btn btn-danger pull-right" data-dismiss="modal" aria-hidden="true">Close</button>
<div class="clearfix"></div>
</div>
<div class="modal-body">
<iframe src="iframe-modal.html"></iframe>
</div>
<div class="modal-footer">
</div>
</div>

我正在寻找一种从 iframe 内部关闭此模式的方法。前任。单击 iframe-modal.html 中的链接以关闭模式。我尝试过但没有成功:

$('#iframeModal', window.parent.document).modal('hide');
$('#iframeModal', top.document).modal('hide');
$('#iframeModal').modal('hide');

最佳答案

您始终可以创建一个全局可访问的函数来关闭 Bootstrap 模态窗口。

例如。

window.closeModal = function(){
$('#iframeModal').modal('hide');
};

然后从 iframe 调用它:

window.parent.closeModal();

关于javascript - 从 iframe 内部关闭 Bootstrap 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15249678/

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