Skip to main content
jwessmiller
Participating Frequently
August 1, 2017
Answered

Check learner internet connection?

Hi Experts! Does anyone know of a way to make a conditional action based on whether the learner has an internet connection?

Basically I want the module to display one thing if there is an active internet connection, and something else if there is not.  Is this possible?  I have both Captivate 8 and Captivate 2017.

Thanks so much for your help!

This topic is closed to new replies. Start a new post to keep the conversation going.
TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
August 1, 2017

This JavaScript will do the trick:

var netConnected = window.location.protocol.indexOf( 'http' );

netConnected will be -1 if not connected and 0 if connected, so you can build your logic and use cp.show() to show what you want.

8 replies

TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
August 1, 2017

This JavaScript will do the trick:

var netConnected = window.location.protocol.indexOf( 'http' );

netConnected will be -1 if not connected and 0 if connected, so you can build your logic and use cp.show() to show what you want.

Translate
jwessmiller
Participating Frequently
August 1, 2017

Thanks for your reply, TLCMediaDesign.

I'm trying to implement your code, but it always seems to be coming back as -1 (whether I'm connected or not).  I'm new to javascript; is there any additional guidance you would be kind enough to give on this?

Translate
TLCMediaDesign
Inspiring
August 2, 2017

Try this:

if(navigator.onLine) {

cp.show("online")

}

else

{

cp.show("offline")

}

Translate
Lilybiri
Legend
August 1, 2017

???? How do you deploy the course without an Internet connection?

Translate
jwessmiller
Participating Frequently
August 1, 2017

Hi Lilybiri,

The learners are issued laptops with my modules pre-loaded on them.

Translate
Lilybiri
Legend
August 1, 2017

Are you aware of the fact that courses not deployed from a webserver will not have all functionality? Unless you create an app of course. Which output do you use: SWF or HTML5? Esoecially HTML5 is very sensitive.

There is no system variable AFAIK that you could use, probably will need a JS solution

Translate