Javascript examples for Browser Object Model:Navigator
The onLine property returns a Boolean value tells whether the browser is in online or offline mode.
This property is read-only.
A Boolean, indicating whether the browser is in online or offline mode.
The following code shows how to check whether the browser is online:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from ww w . jav a 2 s . co m*/ var x = "Is the browser online? " + navigator.onLine; document.getElementById("demo").innerHTML = x; } </script> </body> </html>