弹出系统确认对话框
void plus.nativeUI.confirm( message, confirmCB, title, buttons );
说明:
创建并显示系统样式确认对话框,可设置确认对话框的标题、内容、按钮数目及其文字。 弹出的确认对话框为非阻塞模式,用户点击确认对话框上的按钮后关闭,并通过confirmCB回调函数通知用户点击的按钮索引值。
参数:
- message: ( String ) 必选
确认对话框上显示的内容
- confirmCB: ( ConfirmCallback ) 可选
确认对话框关闭后的回调函数
回调函数中包括Event参数,可通过其index属性(Number类型)获取用户点击按钮的索引值。 - title: ( String ) 可选
确认对话框上显示的标题
- buttons: ( Array[ String ] ) 可选
确认对话框上显示的按钮
字符串数组,每项对应在确认对话框上显示一个按钮,用户点击后通过confirmCB返回用户点击按钮的在数组中的索引值。
返回值:
void : 无平台支持:
- Android - 2.2+ (支持): 对话框上最多只能支持三个按钮,buttons参数超过三个的值则忽略。
- iOS - 4.5+ (支持)
示例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>nativeUI Example</title>
<script type="text/javascript">
// H5 plus事件处理
function plusReady(){
// 弹出提示信息对话框
plus.nativeUI.confirm( "Are you sure ready?", function(e){
console.log( (e.index==0)?"Yes!":"No!" );
}, "nativeUI", ["Yes","No"] );
}
if(window.plus){
plusReady();
}else{
document.addEventListener("plusready",plusReady,false);
}
</script>
</head>
<body>
弹出系统确认对话框
</body>
</html>