How to close fancybox from child window?
parent link:
<a href="feedback.php" id="feed">Provide your feedback here</a>
JQuery code to run fancybox ...
$("#feed").fancybox();
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>
Once the submit button is clicked, I need to close the fancy box on this page using jquery
I tried to use
$.fancybox.close();
parent.$.fancybox.close();
But this does not work for me. If there is any way to close ajax inside this form, please let me know.
The following code should work and worked for many people
parent.$.fn.fancybox.close();
However, I also saw, for example, in this question , jQuery runs in noConflict mode, without the knowledge of the user. If so, you will have to change your script to
parent.jQuery.fn.fancybox.close();
, Firebug Firefox Chrome, , , , .
, ASP.NET.
, ( ) :
$.fancybox({
href: '/ContactUs.aspx',
type: 'iframe',
padding: 60,
width: 465,
height: 670,
maxWidth: 465,
maxHeight: 670,
});
When I click on the FancyBox, it works, but if I send it first, THEN close it fancyBoxwill not close, even if the page is in the same domain.
In the end, I found out that you should set autoSize: false when you open FancyBox:
$.fancybox({
href: '/ContactUs.aspx',
type: 'iframe',
padding: 60,
width: 465,
height: 670,
maxWidth: 465,
maxHeight: 670,
autoSize: false
});
Now it should work. Answer if this works for someone else. Greetings.
Will