The phone alert dialog displays index.html on top of the message

I am working on a phonegap app where I have implemented some dialog warning messages such as no internet connection and push notification, now the problem I am facing is when I receive any dialog I get index.html at the top of the post, how can I get rid of 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>

      

enter image description here

+3


source to share


1 answer


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

cordova plugin add cordova-plugin-dialogs

      

Then you can replace all calls 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 remember that the standard one alert()

blocks the execution of the script, while the plugin version does not block and therefore provides an additional callback.

+8


source







All Articles