Skip to content

Instantly share code, notes, and snippets.

@stevenchan
Created January 22, 2010 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenchan/283811 to your computer and use it in GitHub Desktop.
Save stevenchan/283811 to your computer and use it in GitHub Desktop.
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment