In this tutorial I will explain how to check internet connection using javascript. if connect to internet show alert box Online or not show Offline.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Internet Connection using jQuery</title>
<script type="text/javascript">
function checkconnection() {
var status = navigator.onLine;
if (status) {
alert("online");
} else {
alert("offline");
}
}
</script>
</head>
<body>
<div>
<input type="button" value="Check Connection" onclick="checkconnection()" />
</div>
</body>
</html>
view demo below:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Check Internet Connection using jQuery</title>
<script type="text/javascript">
function checkconnection() {
var status = navigator.onLine;
if (status) {
alert("online");
} else {
alert("offline");
}
}
</script>
</head>
<body>
<div>
<input type="button" value="Check Connection" onclick="checkconnection()" />
</div>
</body>
</html>
No comments:
Post a Comment