window.addEventListener("message", receiveMessage, false);
function receiveMessage(event){
// make sure the message is sent from your minipush server
if(event.origin !== "http://127.0.0.1:8000"){ return; }
// when connection is established / disconnected
// you will be notified with the following messages
if(event.data = "connected"){ return; }
if(event.data = "disconnected"){ return; }
// event.data is the actual message
// modify next line to do whatever you want with it
alert(event.data);
}