“ | 设备的视觉、听觉和触觉通知。 |
navigator.notification.alert(message, alertCallback, [title], [buttonName]);
// Android / BlackBerry WebWorks (OS 5.0 and higher) // iPhone function alertDismissed() { // 进行处理 } navigator.notification.alert( 'You are the winner!', // 显示信息 alertDismissed, // 警告被忽视的回调函数 'Game Over', // 标题 'Done' // 按钮名称 ); // BlackBerry (OS 4.6) // webOS navigator.notification.alert('You are the winner!');
Notification Example
navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels]);
// 处理确认对话框返回的结果 function onConfirm(button) { alert('You selected button ' + button); } // 显示一个定制的确认对话框 function showConfirm() { navigator.notification.confirm( 'You are the winner!', // 显示信息 onConfirm, // 按下按钮后触发的回调函数,返回按下按钮的索引 'Game Over', // 标题 'Restart,Exit' // 按钮标签 ); }
Notification Example
navigator.notification.beep(times);
// 蜂鸣2次! navigator.notification.beep(2);
Notification Example
navigator.notification.vibrate(milliseconds);
// 震动2.5秒 navigator.notification.vibrate(2500);
Notification Example
navigator.notification.vibrate(); navigator.notification.vibrate(2500); // 2500被忽略掉