Reputation: 11
this function is not working
navigator.app.exitApp();
WHILE EXECUTING THE ABOVE LINE ERROR MESSAGE SHOWN AS
[INFO:CONSOLE(984)] "Uncaught TypeError: Object [object Object] has no method 'exec'", source: file:///android_asset/www/cordova-2.2.0.js (984).
<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" src="cordova-2.2.0.js"></script>
<script type="text/javascript" charset="utf-8">
function onLoad()
{
document.addEventListener("deviceready", onDeviceReady, true);
}
function onDeviceReady() {
document.addEventListener('backbutton', exitFromApp, false);
}
function exitFromApp()
{
if(navigator.app)
{
navigator.app.exitApp();
}
else if(navigator.device)
{
navigator.device.exitApp();
}
}
</script>
</head>
<body onload="onLoad();">
<button name="buttonClick" onclick="exitFromApp()">Click Me!</button>
</body>
</html>
Upvotes: 0
Views: 372
Reputation: 1619
Use following ( i think navigator.app
is not avaiable in cordova-2.2.0 ) :
if(navigator.app){
navigator.app.exitApp();
}
else if(navigator.device){
navigator.device.exitApp();
}
Upvotes: 2