• Matt Albertson 9
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I have a lightning component which invokes a third party popup window as a lightbox. The window is served from another domain.
I would like for when that thrid party window closes to call a JavaScript method in my Lightning component to receive some data. 

The best way I found to pass the results is via window.postMessage because the thirda party window and the lightning components are from different domains. 
The quiestion I have is how to receid that postMessage even from my Lightning component. 

I tried adding the below method to my Lighting component's controller but it did not work: 
 doInit : function(component, event, helper) {
        var listener = function(event) {
           //Do work here
       }
        if (addEventListener){
              addEventListener("message", listener, false);
        } else {
              attachEvent("onmessage", listener);
        }
    },

Could you please help me figure this out.