I currently have an image which gets pinged in order to only show a div if the local content is available.
But I think a better implementation is to periodically check for ping, at a 30 second interval, then show an #offline div if the image has not been pinged successfully. This is better as it considers that the status of the connection may change without the page having been reloaded.
Original script:
function ImgLoad(myobj){
var randomNum = Date.now() || new Date().getTime();
var oImg=new Image;
oImg.src="http://192.168.8.1/images/ping2.jpg"+"?rand="+randomNum;
oImg.onload=function(){$("#online").show();}
}
I think I have managed to get the function to poll every 30 seconds, but I've not been able to show a div on error rather than if it pings successfully.
function checkping(){
function ImgLoad(myobj){
var randomNum = Date.now() || new Date().getTime();
var oImg=new Image;
oImg.src="http://192.168.8.1/images/ping2.jpg"+"?rand="+randomNum;
oImg.onload=function(){$("#online").show();}
}
}
setInterval(function(){
checkping()}, 30000)