Parent page JavaScript:
var lastMessage;
setInterval(function() {
var message = localStorage.getItem('message-to-parent');
if (message && message !== lastMessage) {
lastMessage = message;
// your code here
alert('There is a new message for you: ' + message);
}
}, 100);
Child page JavaScript:
localStorage.setItem('message-to-parent', 'hello, my parent!');
If you have a lot of animations and other huge JS code, I'd suggest to increase the timer interval, or better to solve the issue with window
.