Skip to content

Instantly share code, notes, and snippets.

@dvingerh
Created April 21, 2018 13:23
Show Gist options
  • Save dvingerh/7d9071a84bf035dc6484b95856273957 to your computer and use it in GitHub Desktop.
Save dvingerh/7d9071a84bf035dc6484b95856273957 to your computer and use it in GitHub Desktop.
function messageHandler(event) {
// Accessing to the message data sent by the main page
var messageSent = event.data;
// Preparing the message that we will send back
var messageReturned = "Hello " + messageSent + " from a separate thread!";
// Posting back the message to the main page
this.postMessage(messageReturned);
}
// Defining the callback function raised when the main page will call us
this.addEventListener('message', messageHandler, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment