Created
April 21, 2018 13:23
-
-
Save dvingerh/7d9071a84bf035dc6484b95856273957 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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