最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Phonegap alert dialog shows index.html on top of message - Stack Overflow

programmeradmin0浏览0评论

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>

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>

Share Improve this question asked Nov 2, 2014 at 4:34 RijoRijo 471 silver badge8 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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

cordova plugin add cordova-plugin-dialogs

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

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

Example:

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

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

发布评论

评论列表(0)

  1. 暂无评论