Created
November 4, 2016 18:13
-
-
Save tylerbutler/d3af3c38b074855faa6f680b40442096 to your computer and use it in GitHub Desktop.
Simple PostMessage logger
This file contains 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 handlePostMessage(e) { | |
// The actual message is contained in the data property of the event. | |
var msg = JSON.parse(e.data); | |
// The message ID is now a property of the message object. | |
var msgId = msg.MessageId; | |
// The message parameters themselves are in the Values | |
// parameter on the message object. | |
var msgData = msg.Values; | |
console.log(msgId + '\n\n' + JSON.stringify(msgData)); | |
if(msgId == "App_LoadingStatus"){ | |
// Handle a specific message here if you want. | |
} | |
} | |
window.addEventListener('message', handlePostMessage, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment