Page 1 of 1

checking if internet connection exists and loading page if it does

Posted: Wed Dec 10, 2014 11:52 pm
by arron

I am trying to create a page which will check for an internet connection..

this is what I am hoping to do...

if (internet connection exists) {
navigate to page
}

if (internet connection exists) {
javascript error alert "no internet connection exists"
}


checking if internet connection exists and loading page if it does

Posted: Thu Dec 11, 2014 12:29 am
by Matt6607699

Check out this tutorial:
http://devcenter.appery.io/tutorials/...

Basically paste the JS into a JS file and run 3 different events that each execute a function defined in the JS file. Device ready, deviceOnline and deviceOffline. Near lines 120 in the JS file, you will see. $('[dsid="footer"]').text('Online');

If you followed the whole tutorial then your footer will have the name "footer" and that code will change its text.

In an action that you want to execute, add JS on click event(or whatever it is):

var status = $('[dsid="footer"]').text();
if (status==="Online") {
Appery.navigateTo('page_name');
}

if (status==="Offline") {
alert( "no internet connection exists");
}

This should work for you, just follow the tutorial from the start and ignore the actual to do list parts.


checking if internet connection exists and loading page if it does

Posted: Thu Dec 11, 2014 4:41 am
by Yurii Orishchuk

Hello,

Thanks Matt,

Arron please pass that tutorial to understand how offline/online works.

Regards.