ajitksharma
ajitksharma

Reputation: 2019

Exiting apps in HTML5 &Jquery Mobile

I am trying to create a mobile webapp using HTML5 and JqueryMobile. I want to use one Exit button on which the app should be exited. I already tried window.close() and self.close(). That is not working.

Or it will be okay...back button of device automatically handles the exit option of app? Anyone have idea about this?

Upvotes: 0

Views: 1521

Answers (2)

Reinstate Monica Cellio
Reinstate Monica Cellio

Reputation: 26143

On Android you can use...

navigator.app.exitApp();

As far as I'm aware, iOS does not offer a way to programmatically exit an application.

But really, you don't need an exit button. The devices that the app will run on all have home and/or back buttons, which are the correct way to "exit" apps. Let the OS decide what to do with it, not the user.

Upvotes: 3

Oleg Fedorov
Oleg Fedorov

Reputation: 337

Back button is used in navigation so it will just navigate you to previous page in your web view. You need to handle it yourself in back button handler and call

navigator.app.exitApp() 

when you need to exit app. You can add back button handler with command:

document.addEventListener('backbutton', backbuttonHandler, false);

Upvotes: 1

Related Questions