Starting from Ameer Dawood ideea of ping from JS ( pinger ), I've got a problem when the remote IP is a http server, and request HTTP authentification, the browser pop's up the box for user/password. How can I avoid this, If the remote server request auth, we know that the remote server is responding and I need to call alive() function ( doesn't work with http://someBogusUser:someBogusPass@ + ip, beacause it request the password again, I do not want to have the corect password saved on a client side script :) )
The main part of the code is this:
img = new Image();
img.onload = function() { alive()();};
img.onerror = function() { unreachable()();};
img.src = "http://" + ip;
setTimeout(function() { unreachable();}, 1500);
Curently I'm trying to test if I can use a xmlhttprequest readyState and status to see if the remote IP is responding.
Anyone has an ideea on how to do this, or has knowledge of another method to test if a IP is alive from JS. Please don't give me server side solutions (I'm using them now + AJAX).
Thank you
EDIT: I think Web workers will stop any authentication popup from reaching the browser, but they can't handle DOM events (onload, onerror) so workers can't help ... :(