The onLine checker is running fine, but I wanna set 'if' and 'else' in the javascript.
Practical if the status is online... you must be transfered to another link. If the status is offline... the status must show this message 'Re-connecting...' until the device is connected. And I hope after connecting it will check again dhe 'if' and you normaly must be transfered to assigned path.
Here is the HTML code:
<p>Current network status: <span id="status">checking...</span></p>
And here is the javascript code:
var statusElem = document.getElementById('status')
setInterval(function () {
statusElem.className = navigator.onLine ? 'online' : 'offline';
statusElem.innerHTML = navigator.onLine ? 'online' : 'offline';
if ('status'=='online') {
window.location = "http://www.google.com/";
}
else {
statusElem.innerHTML = navigator.onLine ? 'Online' : 'Re-connecting...';
}
}, 250);
Thanks for the time :)
Aucun commentaire:
Enregistrer un commentaire