Click here to Skip to main content
16,017,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good day,

I have a website that opens an iframe inside a jQuery fancybox. Inside the iframe exists an ASP page that has a form. My problem is that when the form is submitted, the fancybox does not close. I know "submit" does not automatically close it, but I have tried many different ways to accomplish this.

Below is the code I have tried:
<script language="JavaScript" type="text/javascript">

    $(function closefancybox() {
        window.parent.jQuery.fn.fancybox.close();
    });    
</script>

<input name="Submit" type="submit" class="style70" value="Submit" onclick="closefancybox()" />


I admit my ignorance in JavaScript and jQuery and am just looking for some suggestions. Thank you!
Posted
Updated 14-Nov-13 12:25pm
v3
Comments
OriginalGriff 11-Feb-14 14:59pm    
Richard - this is off topic, I know, but...
Please don't edit spam questions! This is a request from Chris, and it's for good reasons:
From time to time he tries out new automated spam filters, and the "report" feature is linked to them - if you edit a question the reported material they get is no longer as "spammy" and they get confused as to what is and isn't rubbish.
It also clears the report count, so it takes longer to remove the question automatically!
And...there is a good chance that the "spam" reports may be "credited" to your account rather than the original spammer!

Just hit the "report" button, and if you want to, flag it up in the Spam and Abuse forum:
http://www.codeproject.com/Forums/1652005/Spam-and-Abuse-Watch.aspx
Then one of us with the appropriate permissions will delete the scum bags messages... tee hee....
Richard C Bishop 11-Feb-14 15:17pm    
Very good, thank you for that information.
OriginalGriff 11-Feb-14 15:19pm    
You're welcome!

1 solution

I am not sure what a fancy box is... let me assume that is a JQUERY DIALOG BOX...

Have your design like this...

Page1 --> based on any action, your dialog is opening. Inside that dialog you have an IFrame containing another aspx page, say Page2. In Page1, your JQUERY DIALOG is made from the div having id #dialog.

Page2 --> add the following js code onclick of submit button.

parent.$("#dialog").dialog('close');

So, when you submit the button in Page2 from the IFrame, the parent of the Iframe (which is the dialog) will get closed.

Please reply back it it solves your problem.

Thank you.
 
Share this answer
 
v2
Comments
Richard C Bishop 15-Nov-13 9:58am    
I appreciate your effort, but I am not dealing with a dialog box. I already did exactly what you described, see code above.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900