android-PhoneGap框架中navigator.notification.confirm中的按钮顺序

android-PhoneGap框架中navigator.notification.confirm中的按钮顺序,第1张

概述我在PhoneGap应用中使用以下代码.functionregistrationCallBack(button){if(button==2){window.location.href="login.html";}}navigator.notification.confirm("Areyousure?",regist

我在PhoneGap应用中使用以下代码.

        function registrationCallBack(button){            if(button == 2) {                window.location.href = "login.HTML";            }        }   navigator.notification.confirm("Are you sure ?", registrationCallBack, "Confirmation", "Cancel, Ok");

在iPhone中,按钮顺序正确显示为“取消”和“确定”.
  但是对于AndroID,按钮的顺序相反.依次为“确定”和“取消”.

结果,在回调方法中按钮索引被更改了.

欢迎所有建议:)

谢谢,

解决方法:

尝试使用以下解决方案:

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-PhoneGap框架中navigator.notification.confirm中的按钮顺序全部内容,希望文章能够帮你解决android-PhoneGap框架中navigator.notification.confirm中的按钮顺序所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1084737.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存