Copy link to clipboard
Copied
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 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.
Copy link to clipboard
Copied
???? How do you deploy the course without an Internet connection?
Copy link to clipboard
Copied
Hi Lilybiri,
The learners are issued laptops with my modules pre-loaded on them.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Try this:
if(navigator.onLine) {
cp.show("online")
}
else
{
cp.show("offline")
}
Copy link to clipboard
Copied
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!