我正在开发一个phonegap应用程序,我实现了一些对话框警告消息,例如没有互联网连接和推送通知,现在我面临的问题是,当我得到任何类型的对话框时,我得到index.html在顶部关闭消息,我怎么能摆脱它呢?
<script type="text/javascript" charset="utf-8">
//Check Internaet Connection
function onOnline() {
("")
}
document.addEventListener("offline", onOffline, false);
function onOffline() {
alert("No estas conectado al internet")
}
document.addEventListener("online", onOnline, false);
</script>
答案 0 :(得分:8)
使用Dialogs插件代替:
https://www.npmjs.com/package/cordova-plugin-dialogs
cordova plugin add cordova-plugin-dialogs
然后,您可以将所有对alert()
的调用替换为:
navigator.notification.alert(message, alertCallback, [title], [buttonName])
示例:
navigator.notification.alert(
'You are the winner!', // message
alertDismissed, // callback
'Game Over', // title
'Done' // buttonName
);
请注意标准alert()
阻止脚本执行,而插件版本是非阻塞的,因此提供了可选的回调。