Two way communication between parent document and iFrame

This page is a simple demonstration of two way communication between iFrame and parent document even if they are hosted in different domains. index.html <html> <head> <style> iframe { width:50%; height:50%; } </style> <script> // Listen for iframe loaded event window.addEventListener(“message”, receiveMessage, false); function receiveMessage(event) { if(event.origin !== “http://sandbox.toni-develops.com”) return console.log(‘[parent]’ + event.data); } function … Continue reading Two way communication between parent document and iFrame