Skip to content

Replying to source iframe #1

@kunaakos

Description

@kunaakos

Hi!

I ran into an issue with multiple iframes from different domains communicating with the main window. I cannot create listeners on the main window from the iframes' contexts because of cross-domain restrictions.
The way this was handled before using postmsg-rpc, was by dispatching an event on the window we got the original message from:

window.addEventListener('message', (event) => {
  // ...
  event.source.postMessage(msg, '*')
});

Would it be possible to add this as an option to postmsg-rpc? Something like opts.replyToSender Happy to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions