Detect WIFI Status of application/page — Salesforce

19 May 2016

Hey Guys,

I have come with another interesting scenario which might help people to detect wifi status of your machine. This is a great feature that helps to work applications/pages in offline. mode.

I have come across this situation wherein I wanted my user to stay on a page and give a small online test with clock. Issue was that if wifi goes down for some reason,Clock continued to run as it was made through JavaScript. Clock should also stop in order to avoid wastage of time for user.

I have read many articles and it was written that there is no standard way or function comes in JavaScript that can detect it. A very simple solution could be to hit a public file or url and if response comes ok then that means wifi is working. I have tried to do same thing in Salesforce using Visualforce Remoting that will hit controller’s method on server side and checks for connection.

Below is a short video demonstrating it

https://youtu.be/y_WSDwKwVRM

Full Code:

https://gist.github.com/lkatney/9c58e9cb5f8bb610c8389c25d7c47943

Happy Coding :)

Labels: VisualForce, Salesforce, JavaScript, WifiSignal, OfflineMode

Share this page

0 total shares


Originally published at blog.lkatney.com on May 19, 2016.

Like what you read? Give Lakshay Katney a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.