Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Check learner internet connection?

Community Beginner ,
Aug 01, 2017 Aug 01, 2017

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!

431
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Aug 01, 2017 Aug 01, 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
Community Expert ,
Aug 01, 2017 Aug 01, 2017

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 01, 2017 Aug 01, 2017

Hi Lilybiri,

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 01, 2017 Aug 01, 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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 01, 2017 Aug 01, 2017

Thanks for the heads up- I haven't run into any functionality issues yet (most of my stuff is pretty simple).  I generally publish in HTML5.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Aug 01, 2017 Aug 01, 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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 01, 2017 Aug 01, 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
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Aug 02, 2017 Aug 02, 2017

Try this:

if(navigator.onLine) {

cp.show("online")

}

else

{

cp.show("offline")

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 04, 2017 Aug 04, 2017
LATEST

I need to do a little more studying to understand how cp.show works- but your code worked great as an alert.  Thanks so much!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources