如何关闭从子窗口的fancybox? [英] How to close fancybox from child window?

查看:219
本文介绍了如何关闭从子窗口的fancybox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

父链接:

<a href="feedback.php" id="feed">Provide your feedback here</a>

jQuery的code发起的fancybox是...

jQuery code to initiate fancybox is...

$("#feed").fancybox();

codeS在feedback.php ...

codes in feedback.php...

      <html>
        <head>
<script language="javascript">    
$(document).ready(function(){
    $("#feed_submit").click(function(){
    //Name is alerted
    alert($("#name").val());

    //code to close fancy box(Not working)
    $.fancybox.close();

    });
    });
</script>
        </head>
        <body>
        <form method="post" name="feedback" id="feedback" action="">
                <div>
                    <label>name</label>
                    <input type="text" name="name" id="name"/>
                </div>
                <div>
                    <label>feedback</label>
                    <input type="text" name="content" id="content"/>
                </div>
        <div><input type="button" name="feed_submit" id="submit" value="submit"></div>
    </form>    
    </body>
    </html>

点击

一旦提交按钮,我需要在这个页面本身关闭看中盒的jQuery

我已经尝试使用

$.fancybox.close();
parent.$.fancybox.close();

但是,这并不为我工作。如果有任何选项,关闭这里面ajax的形式,请让我知道。

But this doesn't work for me. If there is any option to close inside this ajax form please let me know.

推荐答案

以下code的应该的工作,并已经工作了许多人

The following code should work, and has worked for many people

parent.$.fn.fancybox.close();

不过,我也看到过,比如<一个href="http://stackoverflow.com/questions/2227096/fancybox-iframe-returns-parent-as-undefined-using-word$p$pss">in这个问题,jQuery的运行于noConflict模式下,用户不知道的。如果这是你的话,你必须修改你的脚本

However, I have also seen, for instance in this question, jQuery being run in noConflict mode, unbeknownst to the user. If this is the case for you, you'd have to modify your script to

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

如果没有这些工作,请使用类似Firebug的工具Firefox或Chrome浏览器的开发者控制台,看是否有错误信息,并反馈给我们报的是什么。

If none of those work, please use a tool like Firebug for Firefox, or the developer console for Chrome, to see if there is an error message, and report back to us what it is.

这篇关于如何关闭从子窗口的fancybox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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