The onLine checker is running fine, but I want to set 'if' and 'else' in the javascript.
Practical if the status is online... you must be transferred 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 the 'if' and you normally must be transferred 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 :)