cordova - Phonegap device on/offline -


i'm trying send app error page if there no internet connection. i've installed relevant plugins , added code below.

i can detect type of connection , if device offline alert message.

i'm struggling send app error page if offline , home page when device online.

// device apis available // function ondeviceready() {     document.addeventlistener("offline", app.onoffline, false); },  // handle offline event // onoffline: function() {      alert("off line"); },  checkconnection: function() {     var networkstate = navigator.connection.type;      var states = {};     states[connection.unknown]  = 'unknown connection';     states[connection.ethernet] = 'ethernet connection';     states[connection.wifi]     = 'wifi connection';     states[connection.cell_2g]  = 'cell 2g connection';     states[connection.cell_3g]  = 'cell 3g connection';     states[connection.cell_4g]  = 'cell 4g connection';     states[connection.cell]     = 'cell generic connection';     states[connection.none]     = 'no network connection';      alert('connection type: ' + states[networkstate]); }, 

could please point me in right direction.

cheers

wayne.

thanks help, redirected when device offline using offline eventlistener call function.

checkstate: function(){     window.location.href = "offline.html"; }, 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -