Category: Javascript

Which iframe posted a message to my window?

What do you do if you have a bunch of different iframes in your web page posting messages? How do you know which iframe a message came from? Even if the iframe document comes from a different origin? This does the trick window.addEventListener (“message”, function (event) { /* for security, always check the origin */ if (event.origin === ‘https://www.example.com’) {… Read more →