Skip to content

Instantly share code, notes, and snippets.

@fer-ri
Created March 15, 2014 10:54
Show Gist options
  • Save fer-ri/9565108 to your computer and use it in GitHub Desktop.
Save fer-ri/9565108 to your computer and use it in GitHub Desktop.
Cordova Exit App Confirm
document.addEventListener("deviceready", deviceisready, false);
function deviceisready(){
alert("Device Ready is called");
document.addEventListener("backbutton", function(e){
if ( $('.ui-page-active').attr('id') == 'mainpage') {
//window.location = "#exitDialog";
exitAppPopup();
}else{
history.back();
};
});
};
function exitAppPopup() {
navigator.notification.confirm(
"Do you really want to close this app?",
function(buttonIndex){
ConfirmExit(buttonIndex);
},
"Confirmation",
"Yes,No"
);
alert("Outside Notification");
//return false;
};
function ConfirmExit(stat){
alert("Inside ConfirmExit");
if(stat == "1"){
navigator.app.exitApp();
}else{
return;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment