Hola tengo algo como esto
Código:
<script>
var img = "";
function stop_the_rest() {
img = false;
}
function continue_the_rest() {
img = true;
}
server_status = new Image();
server_status.onerror = stop_the_rest;
server_status.onload = continue_the_rest;
server_status.src = 'http://images.google.co.cr/intl/es_ALL/images/images_hp.gif';
if ((img) && (img != "")) {
alert("sigamos: " + img);
} else {
alert ("algo salio mal " + img)
}
</script>
ahora bien necesito saber si se cargo cierta imagen pero javascript sigue ejecutandose y onload se ejecuta hasta que la imagen ha sido recivida. Ahora como puedo esperar hasta img defina?... sin ejecutar el resto del codigo? (en esta caso es un if(img)
aqui hay un ejemplo funcionando
http://animenakama.com/js.html