forresto forresto - 1 year ago 114
Javascript Question

javascript: listen for postMessage events from specific iframe

I have multiple iframes in a page. Now I have one

event listener for the page, which gets the messages from all of the iframes. I have a workaround to know from which iframe the message is coming.

I would like to make event listeners for each iframe separately. Is this possible?

Answer Source

No, it's not possible. Best you can do is to have a single handler that routes received messages to helper handlers based on the origin of the message sender.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download