0

i am very new to this mobile dev field and i have a question that have been bothering me for days. i have look up the reference from here. below are the code that he/she used. but unfortunately, when i applied it to mine, the code doesnt work. is it because i access it wrong or there is anything else i missed.

function close_window() {
        if (confirm("Exit?")) {
            navigator.app.exitApp();
        }
    }

here is my html to acccess the script

<div>
<ul>
<li><a data-role="button" data-icon="delete" onclick="close_window();">Exit</a></li>
<ul>
</div>

hopefully my problem can be solved.thank you

Community
  • 1
  • 1

1 Answers1

1

Try this one, but i haven't test it, the source is from here

<!DOCTYPE HTML>
<html>
  <head>
    <title>PhoneGap</title>

        <script type="text/javascript" charset="utf-8" src="cordova-1.5.0.js"></script>      
        <script type="text/javascript" charset="utf-8">

            function onLoad()
            {
                  document.addEventListener("deviceready", onDeviceReady, true);
            }

            function exitFromApp()
             {
                navigator.app.exitApp();
             }

        </script>

    </head>

    <body onload="onLoad();">
       <button name="buttonClick" onclick="exitFromApp()">Click Me!</button>
    </body>
</html>
Community
  • 1
  • 1
Kirk
  • 4,957
  • 2
  • 32
  • 59
  • i tried the code, but i cant exit from the app. then i add some line so that the app will display pop up to confirm user to exit the app. the pop up appear, but when i click 'yes',i still cant exit from the app. – user3171433 Jan 16 '14 at 15:14
  • Did you use button or a link? and just remove confirmation and try to call it directly for the response! let's see – Kirk Jan 16 '14 at 15:17
  • i use button.and i stil cannot exit from the app even after removing the confirmation pop up – user3171433 Jan 16 '14 at 15:30