Well i'm newbie & stuck at a point. And that might have simple solution as well..
I load a page using window.open
using InAppBrowser, While user press hardware backbutton I want to show confirm message before app gets close. I tried some code...
Here is Code
index.html
$(document).ready(function() {
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
var ref = window.open('http://stackoverflow.com/', '_blank', 'location=no,hardwareback=yes');
ref.addEventListener('loadstart', function(event) { SpinnerPlugin.activityStart("Initializing..."); });
ref.addEventListener('loadstop', function(event) { SpinnerPlugin.activityStop(); });
ref.addEventListener('loaderror', function(event) { alert('error: ' + event.message); SpinnerPlugin.activityStop();});
ref.addEventListener('exit', function(event) {
alert('Exit')
});
ref.addEventListener("backbutton", function () { //But This is not triggering...Don't know why..
onConfirm();
})
function onConfirm(button) {
if (button == 1){ //Yes button pressed...
navigator.app.exitApp();
} else{
return false;
}
}
}
});
Even I tried backbutton
event of Cordova..
document.addEventListener("backbutton", onBackKeyDown, false); //Listen to the User clicking on the back button
function onBackKeyDown(e) {
navigator.notification.confirm("Are you sure you want to exit ?", onConfirm, "Confirmation", "Yes,No");
}
It gets triggered properly but after closing inner window.. So again in brief, I want to show same confirm box before closing inner window.
Note: I'm using Cordova 6.1.0
Thanks a-ton in-Advance