2

我想打印與科爾多瓦警報,它只適用於如果我用Ripple Chrome擴展模擬我的應用程序。導航通知警報不工作在科爾多瓦

在我的Samsung Galaxy S3中,單擊按鈕時沒有任何反應。

我正在使用Cordova 3.6.3-0.2.13。 我已將以下插件添加到我的項目中: org.apache.cordova.dialogs和 org.apache.cordova.vibration。 (如果我輸入 「科爾多瓦插件LS」 他們都出現)

<html> 
<head> 
<script type="text/javascript" charset="utf-8"> 

     function getInfo() { 
     navigator.notification.alert(
       'Model: ' + device.model, // message 
       null,   // callback 
       'Info',   // title 
       'Ok'     // buttonName 
     ); 
    } 
    </script> 

    <meta charset="utf-8" /> 
    <meta name="format-detection" content="telephone=no" /> 
    <meta name="msapplication-tap-highlight" content="no" /> 
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> 
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
    <link rel="stylesheet" type="text/css" href="css/index.css" /> 
    <title>Hello World</title> 
</head> 
<body> 
    <div class="app"> 
     <h1>Apache Cordova</h1> 
     <div id="deviceready" class="blink"> 
      <p class="event listening">Connecting to Device</p> 
      <p class="event received">Device is Ready</p> 
     </div> 
     <button id="gobutton" type="button" onclick="getInfo()">CLICK ME</button> 
    </div> 
    <script type="text/javascript" src="cordova.js"></script> 
    <script type="text/javascript" src="js/index.js"></script> 
</body> 
</html> 

雖然我index.js是:

var app = { 
    // Application Constructor 
    initialize: function() { 
     this.bindEvents(); 
    }, 
    // Bind Event Listeners 
    // 
    // Bind any events that are required on startup. Common events are: 
    // 'load', 'deviceready', 'offline', and 'online'. 
    bindEvents: function() { 
     document.addEventListener('deviceready', this.onDeviceReady, false); 
    }, 
    // deviceready Event Handler 
    // 
    // The scope of 'this' is the event. In order to call the 'receivedEvent' 
    // function, we must explicitly call 'app.receivedEvent(...);' 
    onDeviceReady: function() { 
     app.receivedEvent('deviceready'); 
    }, 
    // Update DOM on a Received Event 
    receivedEvent: function(id) { 
     var parentElement = document.getElementById(id); 
     var listeningElement = parentElement.querySelector('.listening'); 
     var receivedElement = parentElement.querySelector('.received'); 

     listeningElement.setAttribute('style', 'display:none;'); 
     receivedElement.setAttribute('style', 'display:block;'); 

     console.log('Received Event: ' + id); 
    } 
}; 

app.initialize(); 

你能幫助我嗎?在此先感謝

+0

嘗試移動你的'的getInfo()'函數你'index.js'底部 – 2014-10-06 16:12:00

回答

0

如果還是不行試試這個:

navigator.notification.alert("string",function(){}, "string");