0

I want to show a confirmation dialog(Are you sure?) with 2 button "Yes" and "Cancel" before exit when the user press the native back button on the home(first) screen. And based on the buttons the decision should be made.

My question is where do I write the confirm dialog(/popup) code. I tried inside onExit(), but its not working.

Thanks.

Zee
  • 8,420
  • 5
  • 36
  • 58

1 Answers1

0

You have to attach on the right browser resp. native events. Here are the best guesses I found:

That piece of code appears not to work on iOS, not sure about Android.

Another possibility would be to make your page open in a new window or use a redirect. This way your application would be the first page in window.history stack and there will be no back beyond your start page.

GL Chris

Community
  • 1
  • 1
cschuff
  • 5,502
  • 7
  • 36
  • 52
  • well I brought up some more possibilities. any comments on those? what else did you try? – cschuff Sep 09 '14 at 12:41
  • Hi, sorry for such a late reply. Off late I found that document.addEventListener("backbutton", function(e){ e.preventDefault(); /*My code*/}) works fine. The only thing I had to add is in config.xml. – Zee Feb 23 '15 at 10:56