Vote count:
0
This all happen on page load without click event call:-
Here is updated code, In this I am trying to check internet connection is on or not. If connection is off then 'link' on the will be automatically disable(non clickable) and it bgcolor changes to red.
And if connection is off 'link' will be automatically get enable(clickable) and it bgcolor changes to green. However I am missing some thing:
code:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://ift.tt/1hdlDIq">
<script src="http://ift.tt/15195HW"></script>
<script src="http://ift.tt/1hdlEfI"></script>
</head>
<style>
.connected{ background-color:green;}
.diconnected{background-color:green;}
#link1{
width: 100px;
height: 200px;
border: #0FF 1px solid;
}
</style>
<body>
<a href="#" id="link1"><img src="images/network.png"> My status</a>
</body>
<script>
window.onload=function() {
var tId = setInterval(function() {
document.getElementById("link1").disabled=!navigator.onLine;
},500);
if (navigator.onLine) {
$("link1").bind('click', true).addClass('connected').removeclass('diconnected');
} else {
$('.link1').unbind('click', false);
$("link1").bind('click', true).addClass('diconnected').removeclass('diconnected');
}
}
</script>
</html>
Thanks for help.
asked 28 secs ago
Aucun commentaire:
Enregistrer un commentaire