Skip to content

Instantly share code, notes, and snippets.

@perrygovier
Created June 13, 2013 15:37
Show Gist options
  • Save perrygovier/5774705 to your computer and use it in GitHub Desktop.
Save perrygovier/5774705 to your computer and use it in GitHub Desktop.
Handy tool for Cordova editors so alert messages are pretty if on a mobile device but still work in a browser
isMobile = false;
document.addEventListener("deviceready", function(){isMobile = true}, false);
notify = function(msg){
if(isMobile){
navigator.notification.alert(
msg, // message
null, // callback
'Alert', // title
'Ok' // buttonName
);
}else{
alert(msg);
}
}
// Example Use
notify('Stop Poking Me!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment