I am trying to understand how "Offline.js" works. I have the following script which I have working under the following circumstances:
Device connected to the internet via WiFi. If I disable the WiFi, the offline events are triggered. When I enable the WiFi the web page returns to running as normal.
The issue I have, if I display/turn off the Wifi access point rather than the device's WiFi, after three or more attempts to connect to the internet offline fails and the browser "Chrome" displays the default message "Not connected to the Internet".
Should Offline.js work under those circumstances, i.e WiFi access point turned off.
The script I am using is:
var active;
var pageno = "<?php echo $pageNo;?>";
var totalPages_fids = "<?php echo $totalPages_fids;?>";
var RefreshRate = "<?php echo $ArriveScreenRefreshRate;?>";
var pageStrNo = "<?php echo $pageStrNo;?>";
var run = function(){
if (Offline.state === 'up') {
//Offline.check();
Offline.options = {
checkOnLoad: true,
requests: true,
checks:{
image: {
url: 'tiny-image.gif'},
active: 'image'}
}
active = 1;
console.log(Offline);
console.log(active);
if (active == 1) { // IF VAR "ACTIVE" == 1 EXECUTE THE CODE BELOW
if(pageno == totalPages_fids) {
window.setTimeout(function(){
window.location.href = "depart_ad24.php";
}, RefreshRate);
} else {
function IsBytec()
{
try
{
if(window.external.getBytProperty('SVNRev'))
return true;
}
catch(err){}
return false;
}
function ScrRefresh() {
var URL = 'depart24.php?pageNum_fids='+pageStrNo+'&totalPages_fids='+totalPages_fids+'';
if (IsBytec()) {
window.external.Browser(1).parentWindow.location.href = URL;
} else {
window.location = URL;
}
return;
}
window.setInterval(ScrRefresh, RefreshRate)
}
}
}
}
setInterval(run, RefreshRate);
active = 0;
console.log(active);
When I run the page and monitor the process in Chrome console this is what I see.
Console:
And then the browser displays:
Many thanks in advance for your comments and time.