2016-11-14 22 views
0

我想使用navigator.app.exitApp();通過對話框退出我的cordova應用程序。我還安裝了cordova對話框插件。navigator.app.exitApp();使用科爾多瓦對話框插件時不起作用

這是我的代碼:

<script> 
    function onConfirm(buttonIndex) { 
alert('You selected button' + buttonIndex); 
} 


navigator.notification.confirm(
'Do you want to exit app?', // message 
onConfirm,   // callback to invoke with index of button pressed 
'Exit',   // title 
['Yes','No']  // buttonLabels 
); 


    onConfirm(buttonIndex) { 
if (buttonIndex==2){ 
navigator.app.exitApp(); 
} 
} 
</script> 


<button onclick="onConfirm(); return false;">Exit</button> 

但它不工作。

我該如何解決它?

感謝高級。

回答

1

穆赫辛ALK試試這個已經被選中,並正在

<input type="button" value="exit" id="exit" onclick="payrent();" /> 

function payrent() { 
    navigator.notification.confirm(
     'You are about to leave this app and open your default web browser. Continue?', 
     payrent1, // <-- no brackets 
     'Leave App?', 
     ['Ok', 'Cancel'] 
    ); 
} 

function payrent1(buttonIndex) { 
    if (buttonIndex == 1) { 
     navigator.app.exitApp(); 
    } 
} 
+0

它worked.thank你這麼多。 –

相關問題