When I use jQuery event listener to handle message event, like below:
$(window).on('message', function(e) {
var data = e.data; // data = undefined
});
data is undefined! I’m sure that I have passed data to current window. Because if I use “addEventListener”, everything goes well!
So, what’s the problem?
jQuery might be preprocessing the event’s
dataproperty, and this operation may not properly support themessageevent (yet).Try using the
originalEventproperty to fetch your data: