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
1 Answer
Reset to default 8Use 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.