How to detect the Internet connection is offline or not using JavaScript? Last Updated : 04 Oct, 2024 Comments Improve Suggest changes Like Article Like Report Detecting if the internet connection is offline using JavaScript involves utilizing the navigator.onLine property. This property returns false when the browser is offline and true when connected, allowing you to respond to network connectivity changes in real-time.Syntax: function isOnline() { return ( navigator.onLine) }Example: In this example we hecks the browser's online status using the navigator.onLine property. It updates the page with "Online" or "Offline" based on the connection status. HTML <!DOCTYPE html> <html> <head> <title> detect the Internet connection is offline or not </title> </head> <body> <p> Click the button to check if the browser is online. </p> <button onclick="isOnline()"> Click Me </button> <p id="demo"></p> <script> function isOnline() { if (navigator.onLine) { document.getElementById( "demo").innerHTML = "Online"; } else { document.getElementById( "demo").innerHTML = "Offline"; } } </script> </body> </html> Output: Supported Browsers The minimum version of browsers that supports the property: Google Chrome: 14.0Internet Explorer: YesFirefox: 3.5Safari: 5.0.4Opera: Yes Comment More infoAdvertise with us Next Article How to detect the Internet connection is offline or not using JavaScript? A ayushsaxena77 Follow Improve Article Tags : JavaScript Web Technologies HTML JavaScript-Misc Similar Reads How to detect flash is installed or not using JavaScript ? The task is to detect whether the user has installed Adobe Flash player or not with the help of JavaScript. we're going to discuss 2 techniques. Approach: Create a ShockwaveFlash.ShockwaveFlash object.If the instance's value is true, Flash is installed.If any error occurred, Use navigator.mimetypes 2 min read How to get a dialog box if there is no internet connection using jQuery ? In this article, we will see how to check the internet connection using jQuery. We will be using navigator.onLine which will return true if an internet connection is available otherwise it will return false. Syntax: navigator.onLine Returns: True: If the internet connection is available.False: If th 2 min read How to check the user is using Internet Explorer in JavaScript? There may arise cases when we need to check the browser being used. Some features of your website may not be supported in older browsers like Internet Explorer(IE). There are different ways to check the version of Internet Explorer being used. Syntax-1: For Internet Explorer 10 or older var ua = win 2 min read How to Detect Network Speed using JavaScript? Network speed detection in JavaScript involves measuring the time it takes to download a known file or resource and calculating the download speed. To calculate the speed of the network a file of known size is chosen from a server to download. The time taken to start and complete the download is rec 2 min read How to check whether the background image is loaded or not using JavaScript ? In this article, we will check whether the background image is loaded or not using JavaScript. In JavaScript, onload event is used to check whether a window is loaded or not. Similarly, we can use that event to check whether a particular element has loaded or not. There are two ways in which we can 2 min read Like