我有一个链接调用名为 class="iframe"的弹出 View 。 我计划在那些弹出窗口中设置一个表单,但我的问题是我需要在单击提交然后关闭我的原始页面后关闭那些弹出窗口,否则我的弹出窗口背景将自行刷新。 我的脚本:
<script src="<?php echo base_url(); ?>template/popup/jquery.colorbox.js"></script>
<script type="text/javascript">
var $ = jQuery.noConflict();
$(document).ready(function(){
//Examples of how to assign the Colorbox event to elements
$(".iframe").colorbox({iframe:true, width:"50%", height:"78%"});
//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
});
</script>
<a class='iframe' href="#">POP UP </a>
最佳答案
查看 PostMessages
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
您应该能够从父页面发送消息。一旦收到消息,您的窗口应该能够自行关闭。 (这也适用于跨域)
关于javascript - iframe 提交后关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32240036/