javascript - jQuery iframe 模式关闭表单提交

标签 javascript jquery html forms

我有一个带有 iframe 的 jQuery 模态对话框,iframe 包含一个表单。当用户提交表单时,我想关闭模态对话框。

我该怎么做?

index.php 上的 jquery 模态脚本:

<script type="text/javascript">
function showRegDialog(url) {
    $(function() {
            var $this = $(this);
            var horizontalPadding = 30;
            var verticalPadding = 30;
            $('<iframe id="externalSite" scrolling="no" frameborder="0" class="externalSite" src="' + url + '" />').dialog({
                title: ($this.attr('title')) ? $this.attr('title') : 'Choose your location',
                autoOpen: true,
                width: 700,
                height: 700,
                modal: true,
                resizable: true,
                autoResize: true,
                overlay: {
                    opacity: 0.5,
                    background: "black"
                }

            }).width(700 - horizontalPadding).height(700 - verticalPadding);            

    });
}
</script>

index.php 上的链接调用 showRegDialog 模式:

<a href="javascript:showRegDialog('/register.php');">Register now</a>

这是register.php的内容

<html>
<body>
<form action="" method="POST">
<input type="text">
<input type="submit">
</form>
</body>
</html>

最佳答案

像这样在父窗口中调用 javascript 函数:

parent.yourJsFunction();

将它放在表单的“onsubmit”中。

关于javascript - jQuery iframe 模式关闭表单提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4667829/

相关文章:

javascript - 使 div 和输入宽度为父级的 100%

html - 如何使 table 标签和 div 标签的高度行为相同?

javascript - 如何通过邮政编码确定美国县?

javascript - 预期声明但发现 '"显示 :none ;"' . 跳到下一个声明

javascript - 如何在选择 Bootstrap 中附加选项?

javascript - 如何由特定用户运行Parse Cloud Code?

jquery - fancybox 中的背景图片?

javascript - JS - 从字符串中删除每个关闭的 html 标签

jquery - 如何正确使用 fullpage.js 的 onLeave() 函数?

jquery - 使用 jquery 翻转面板