When I use jQuery event listener to handle message event, like below:
$(window).on(\'message\', function(e) { var data = e.data; // data = undefined });
Some browsers use the "onmessage" event. I suggest a little improvement to the previous answer for increased compatibility:
$(window).on("message onmessage", function(e) { var data = e.originalEvent.data; });