如何关闭从子窗口的fancybox?窗口、从子、fancybox

2023-09-10 17:24:46 作者:霸气de小男生

父链接:

<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();

不过,我也看到过,比如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.