jQuery iframe模式关闭表单提交 [英] jQuery iframe modal close on form submit

查看:87
本文介绍了jQuery iframe模式关闭表单提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我该怎么做?



在index.php上的jquery模态脚本:

 < script type =text / javascript> 
函数showRegDialog(url){
$(function(){
var $ this = $(this);
var horizo​​ntalPadding = 30;
var verticalPadding = 30 ;
$('< iframe id =externalSitescrolling =noframeborder =0class =externalSitesrc =''+ url +'/>')。dialog({
title:$ this.attr('title'))?$ this.attr('title'):'选择你的位置',
autoOpen:true,
width:700,
height:700,
modal:true,
resizable:true,
autoResize:true,
覆盖:{
不透明度:0.5,
背景:黑色
}

})。width(700 - horizo​​ntalPadding).height(700 - verticalPadding);

});
}
< / script>

链接到index.php以调用showRegDialog模式:

 < a href =javascript:showRegDialog('/ register.php');>立即注册< / a> 

这是register.php的内容

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


解决方案

p>

  parent.yourJsFunction(); 

将其放入您的表单中的onsubmit。

I have a jQuery Modal dialog with an iframe in it, the iframe includes a form. When a user submits the form, I would like to close down the modal dialog.

How can I do that?

jquery modal script on index.php:

<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>

link on index.php to call showRegDialog modal:

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

This is the content of the register.php

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

解决方案

Call javascript function in parent window like this:

parent.yourJsFunction();

put it in "onsubmit" in your form.

这篇关于jQuery iframe模式关闭表单提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆