Check Internet Connection using HTML and JavaScript

Опубликовано: 31 Январь 2026
на канале: Skptricks
2,342
16

Download Linkhttp://www.skptricks.com/2018/03/chec...

Check Internet Connection using JavaScript

Today, We are going to learn how to check internet connection using html and javascript. We have used pure javascript to check offline and online status of internet connection. Nowadays these two new events supported by most of the browser: "online" and "offline".These two events are fired on the body of each page when the browser switches between online and offline mode. Additionally, the events bubble up from document.body, to document, ending at window.

You can register listeners for these events by following below steps :
Using addEventListener on the window, document, or document.body.
By setting the online or offline properties on document or document.body to a JavaScript Function object.

Check internet connection
Lets see the complete example to check online and offline status of internet connection, using below javascript code.
check-internet-status.html