Created
June 13, 2013 15:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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