-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replying to source iframe #1
Comments
I'm not sure I understand the issue correctly. Can you not pass https://github.com/tableflip/postmsg-rpc#callerfuncname-options |
Yeah, but to get the return value, I need to pass This is what I'm currently doing, exposing functions with
If I'm missing something, and there's a better way, lemme know. |
You should use the default - |
correction: *not allowed from cross-domain iframes - that's a confusing typo to make, sry If I use the default, I need the above hack. That works. |
In the parent can you pass |
I have several, dynamically inserted iframes on the page, and several of those will call the same exposed method, so that approach doesn't work :( |
Gotcha, I think your hack is ok for now. I wanted to add this a while ago but my primary use for this library is in a webextension context where the postMessage API is similar but not the same. I'd like to add it in a way that allows it to be used in a web page but also in a web extension. FYI the web extension API https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/onMessage |
I was thinking about sth like:
This doesn't break compatibility AFAIK, but makes the config a bit more confusing, since setting Either way, happy to submit a PR, but wasn't sure about how to approach this. |
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:
Would it be possible to add this as an option to postmsg-rpc? Something like
opts.replyToSender
Happy to submit a PR!The text was updated successfully, but these errors were encountered: