Skip to content
  • Home
  • Contact
  • COVID
  • My Portfolio
Sonahang RaiPersonal Blogs
  • Home
  • Contact
  • COVID
  • My Portfolio
internet status
Javascript

Check internet status with Javascript

On November 20, 2022 by Sonahang Rai

Javascript is so powerfull. Nowadays we can see that there are lots of web app being used offline with the PWA implementation. Thats because javascript has the ability to detect if the client is connected to the internet or not.

We can simple listen to the javascript window to know about the clients connectivity status. And we can simply perform anything we want after the listened value is satisfied.

window.addEventListener("online", function () {
  //Online Listener
  //Perform anything you want in your website
  //When this online event is satisfied
});
window.addEventListener("offline", function () {
  //Offline Listener
  //Perform anything you want in your website
  //When this offline event is satisfied
});

You can check my implemtation video in youtube.

Archives

  • November 2022
  • November 2021
  • August 2021
  • April 2021
  • March 2021
  • August 2020
  • July 2020
  • April 2020

Calendar

March 2023
S M T W T F S
 1234
567891011
12131415161718
19202122232425
262728293031  
« Nov    

Categories

  • Javascript
  • Next
  • React
  • SEO
  • Web Design (Slicing)
  • Web Design Tutorials
  • Wordpress

Copyright Sonahang Rai 2023 | Theme by ThemeinProgress | Proudly powered by WordPress