PhoneGap中navigator.notification.confirm的用法详解

时间:2022-01-26 18:54:30
navigator.notification.confirm('您确定要退出程序吗?', showConfirm, '退出程序', '确定,取消');

function showConfirm(button) {
if( button== ) {
document.removeEventListener("backbutton", eventBackButton, false);//注销返回键
navigator.app.exitApp();//退出app程序
}
}

用法:navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels]);

message:对话框信息。(字符串类型)
confirmCallback:按下按钮后触发的回调函数,返回按下按钮的索引(1、2或3)。(函数类型)
title:对话框标题。(字符串类型)(可选项,默认值为“Confirm”)
buttonLabels:逗号分隔的按钮标签字符串。(字符串类型)(可选项,默认值为“OK、Cancel”)

有上面代码可以看出,回到函数接收按钮返回值通过button即可。

转载请注明:http://www.tea119.com