window.addEventListener('message', function(event) { if (event.data.hasOwnProperty('redirect')) { window.location = event.data['redirect']; } });