Phonegap警报对话框在消息顶部显示index.html [英] Phonegap alert dialog shows index.html on top of message

查看:113
本文介绍了Phonegap警报对话框在消息顶部显示index.html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个phonegap应用程序,该应用程序实现了一些对话框警告消息,例如没有互联网连接和推送通知,现在我面临的问题是,当我得到任何类型的对话框时,我都会获得index.html删除邮件,我该如何摆脱它?

I'm working on a phonegap app which i implemented some dialog warning messages such as no internet connection and push notification, now the problem I'm facing is that when i get any type of dialog i get index.html in top off the message, how can i get rid off it?

       <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>

推荐答案

请改用Dialogs插件:
https://www.npmjs.com/package/cordova-plugin-dialogs

Use the Dialogs plugin instead:
https://www.npmjs.com/package/cordova-plugin-dialogs

cordova plugin add cordova-plugin-dialogs

然后,您可以将所有对alert()的呼叫替换为:

Then you can replace all calls to alert() with:

navigator.notification.alert(message, alertCallback, [title], [buttonName])

示例:

navigator.notification.alert(
    'You are the winner!',  // message
    alertDismissed,         // callback
    'Game Over',            // title
    'Done'                  // buttonName
);

请注意,标准的alert()会阻止脚本执行,而插件版本是非阻止的,因此提供了可选的回调.

Just be aware that the standard alert() blocks script execution, while the plugin version is non-blocking and hence provides an optional callback.

这篇关于Phonegap警报对话框在消息顶部显示index.html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆