Articles → JavaScript → Check if user is connected to internet or not in JavaScript
Check if user is connected to internet or not in JavaScript
Navigator.onLine
Example
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script>
alert(navigator.onLine);
</script>
</head>
<body> </body>
</html>