Skip to content

Instantly share code, notes, and snippets.

@bingoohuang
Last active August 29, 2015 14:04
Show Gist options
  • Save bingoohuang/c16c74cf790e6987e969 to your computer and use it in GitHub Desktop.
Save bingoohuang/c16c74cf790e6987e969 to your computer and use it in GitHub Desktop.
Try load images by sequence until 404 found
<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