Navigator onLine Property - Javascript Browser Object Model

Javascript examples for Browser Object Model:Navigator

Description

The onLine property returns a Boolean value tells whether the browser is in online or offline mode.

This property is read-only.

Return Value

A Boolean, indicating whether the browser is in online or offline mode.

The following code shows how to check whether the browser is online:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials