警告对话框
[!TIP|labelVisibility:hidden|iconVisibility:hidden] navigator.notification.alert(message, callback, title, buttonLabel)
支持平台:
- Android
- iOS
参数说明
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
message | String | 是 | 提示内容 |
callback | Function | 是 | 回调函数,可为null |
title | String | 是 | 标题文字,默认文字Alert |
buttonLabel | String | 否 | 按钮文字,默认文字OK |
callback
函数无返回值,点击buttonLabel
对应的按钮触发;
示例代码
// 引用js
<script src='supconit://hcmobile.js'></script>
<script>
// 监听’deviceready‘事件
document.addEventListener('deviceready', onDeviceReady, false)
function onDeviceReady(){
navigator.notification.alert(
'You are the winner!',
function () {
console.log('alertDismissed');
},
'Game Over',
'Done'
);
}
</script>