1

我正在使用 cordova2.1.0 开发一个 android 应用程序,在此我使用 navigator.notification.alert 并在单击警报的 Ok 按钮时使用回调函数。我弹出警报,但单击“确定”时未调用回调函数。我使用cordova2.0.0版本让它工作,但在cordova2.1.0中不起作用。请帮我。我正在使用的代码如下:

  function WriteReviewAlert(){
        navigator.notification.alert(
            'Alert message.',  // message
             gotoSettings,         // callback
            'Test',            //title
            'OK'                  // buttonName
        );
}


  function gotoSettings()
{
    $.mobile.changePage( 'settings.html', { transition: "slide"} );
}
4

1 回答 1

1

检查这个它可能对你有帮助..

<!DOCTYPE html>
    <html>
      <head>
        <title>Notification Example</title>
        <script type="text/javascript" charset="utf-8" src="cordova-1.9.0.js"></script>
        <script type="text/javascript" charset="utf-8">

            document.addEventListener("deviceready", onDeviceReady, false);
            // PhoneGap is ready       
            function onDeviceReady() {

            }

        function onConfirm(button) {
            alert('...');
        }

                function showConfirm() {
            navigator.notification.confirm(
            'You are the best!',  // message
            onConfirm,              // callback to invoke with index of button pressed
            'TEST',            // title
            'OK'          // buttonLabels
        );
        }
    </script>
  </head>
  <body>
    <p><a href="#" onclick="showConfirm(); return false;">Show Confirm</a></p>
  </body>
</html>
于 2013-01-08T06:06:11.713 回答