Reputation: 21934
I have a window with a link.
When the link is clicked, a modal box opens (it's loading another page in an iframe).
The iframe contains a login. When the user logs in, I would like the modal box to close and send a message back to the original page.
How do I go about this?
Is there a javascript event or a way to dispatch a message between a window and a related iframe?
Upvotes: 4
Views: 1317
Reputation: 69915
You can call parent window
JavaScript method from an iframe like this.
window.parent.methodName();
If you want to access any element from parent window.
$('elementSelector', window.parent).doAnyJQueryOperation();
If you want send a message to parent window.
window.parent.alert('Message from iframe');
Upvotes: 4