嘗試使用以下解決方案:
function showConfirm(message, callback, buttonLabels, title){
//Set default values if not specified by the user.
buttonLabels = buttonLabels || 'OK,Cancel';
title = title || "default title";
//Use Cordova version of the confirm box if possible.
if(navigator.notification && navigator.notification.confirm){
var _callback = function(index){
if(callback){
callback(index == 1);
}
};
navigator.notification.confirm(
message, // message
_callback, // callback
title, // title
buttonLabels // buttonName
);
//Default to the usual JS confirm method.
}else{
invoke(callback, confirm(message));
}
}
這裏是你將如何使用它:
var message = "Would you like to proceed?";
var title = "Important Question";
//The first element of this list is the label for positive
//confirmation i.e. Yes, OK, Proceed.
var buttonLabels = "Yes,No";
var callback = function(yes){
if(yes){
alert('Proceed');
}else{
alert('Do Not Proceed');
}
};
showConfirm(message, callback, buttonLabels, title);
根據Android的大腦,我創建了一個bug來跟蹤這個https://issues.apache.org/jira/browse/CB-889 – 2012-06-11 17:48:18
它的一個「功能」不是一個bug。 – DaveWalley 2013-01-15 17:30:44
您可能不想「解決」這個問題,因爲用戶期望特定平臺上某些地方的按鈕。 – 2014-07-24 19:46:12