I have a form that has been called using a iframe, now when that form is submitted i want to catch a response in the main site from where the iframe was called and depending on it would enable/disable a button in main page.
Please anyone help me out..
You could use window.postMessage API. Its is a HTML5 feature and not all browsers support this feature
In the Iframe and Parent Site you need a check if the browser does support postMessage
if (typeof window.postMessage != 'undefined') { }
you can send your message with
window.parent.postMessage("test","*");
In your Parent (Main Site) you need an eventlistener
window.addEventListener('message', receive, false);
function receive(evt)
{
// handles the event
}
Just use parent
from within the iframe once the form is submitted.
parent.document.getElementById('xx').innerHTML = "hello world";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With