Reputation: 14717
I am using Fancybox 2.
I am trying to find a way to information from the parent from within the iframe window. Here is my situation:
open Fancybox iframe from the parent
after the iframe is opened, user clicks on a button. This click needs info from the parent, for which I hope to call a function in the parent. Please note that clicking on this button should not close the iframe.
Is this something doable in Fancybox 2? I read many posts at SO and am unable to figure this out.
Thanks for any help!!!
Upvotes: 0
Views: 4123
Reputation: 41143
If in your parent page you have this function
function fnParent() {
// returns some data
};
... from within the iframed page you just need to call that function like :
parent.fnParent();
Notice that if you open fancybox in iframe
mode, whatever interaction or click
events inside the iframe
will never close fancybox unless one clicked element calls the parent.jQuery.fancybox.close()
method.
Also notice that the iframed page may need to have jQuery included and its own scripts and functions to process the response from the parent page.
See JSFIDDLE
Upvotes: 1