I need some help with my html code. I need to integrate javascript in it which upon loading checks whether internet is available or not. If active it should perform specific task, else it should show "no internet".
`<html>
<head>
</head>
<body onload="myClickHandler();
startTime()">
<script language="JavaScript">
var t;
document.onclick = myClickHandler;
function myClickHandler() {
clearTimeout(t);
t = setTimeout("location.href='index.html'", 60000);
//for refreshing the page in every 60 sec.
}
</script>
<h1> test </h1>
<script type="text/javascript">
var url = "https://www.google.co.in";
var img = new Image();
img.src = url;
img.onerror = function()
{
// If the server is down, do that.
alert ("no connection");
}
img.onload = function()
{
// If the server is up, do this.
//some task to perform.
return true;
}
</script>
</body>
</html>`
This is what i code, but page is keep on loading after the performance also we need to manually stop the loading.