How Can I Return A Value From A postMessage() call asynchronously?

10,864

I iframe window needs to listen for the "message" event, process the message, and then send a postMessage back to the window of the messenger.

You can read about the API here: window.postMessage().

David Walsh has also written a good tutorial on how to do this.

I hope this helps!

Share:
10,864
Harry Manback
Author by

Harry Manback

Professional code monkey for hire.

Updated on June 04, 2022

Comments

  • Harry Manback
    Harry Manback almost 2 years

    I'm trying to get a value from local storage on a site loaded through an Iframe. I'm able to send a message to the site within the iframe through postMessage, but haven't figured out how to return data from the postMessage call. I've looked into promises, but haven't figured out how to get it working.

    Anyone have an idea?