Last active
August 29, 2015 14:04
-
-
Save bingoohuang/c16c74cf790e6987e969 to your computer and use it in GitHub Desktop.
Try load images by sequence until 404 found
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
</body> | |
<script> | |
(function tryLoadImages(index) { | |
var img = document.createElement('img'); | |
img.src = "http://127.0.0.1:7001/" + index + ".jpg"; | |
img.onload = function() { | |
document.body.appendChild(img); | |
document.body.appendChild(document.createElement('p')); | |
tryLoadImages(++index); | |
}; | |
img.onerror = function() { | |
console.log(index); | |
}; | |
})(0); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment