Sto scrivendo un'app che utilizza principalmente il codice lato server. Ma gli errori vengono generati, indipendentemente da ciò che mai con una connessione corretta. Per favore aiuto.
function checkConnection() {
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";
if (states[networkState]="Unknown connection")
{
alert("Get in a trusted Connection: " + states[networkState]);
}
else if (states[networkState]="No network connection")
{
alert("Warning: " + states[networkState]+": Please Get Connection and Reconnect");
}
else
{
var ref = window.open("http://70.61.212.124:8083", "_self", "location=no");
}
}
risposte:
1 per risposta № 1Nella tua dichiarazione
if (states[networkState]="Unknown connection")
{
alert("Get in a trusted Connection: " + states[networkState]);
}
stai assegnando
states[networkState]="Unknown connection"
così valore di
states[networkState]
sarebbe sempre "Unknown connection"
e questo if
la condizione sarebbe sempre vera, poiché l'assegnazione restituisce sempre vera.
spero che cosa intendi veramente fare
states[networkState]=="Unknown connection"