私のスクリプトは、画像をロードするためのコードをテーブルに追加します。ただし、テーブルの内容から画像リンクを解釈します。これにより、エラーのない画像が読み込まれることがあります。最初の画像が失敗した場合に読み込まれるプレースホルダー画像を作成しましたが、このプレースホルダーが読み込まれなかった場合、スクリプトは無限ループに入ります。
$(document).ready(function() {
$('tr[id^="mini"]').each(function(index) {
var s = $(this).find('td:first');
var product = s.text().replace(/\s+/g, '');
s.append('<br><a href="/-p/' + product + '.htm" target="_blank">View Live</a><br><a title="Click for bigger image" href="/PhotoDetails.asp?ShowDESC=Y\&ProductCode=' + product + '" onclick="window.open(\'/PhotoDetails.asp?ShowDESC=Y\&ProductCode=' + product + '\',\'Option\',\'scrollbars=yes,menubar=no,status=no,location=no,width=600,height=640\'); return false;" target="_blank"><img src="/v/vspfiles/photos/' + product + '-0.jpg" border="0" style="max-width:150px;max-height:150px" id="monkey-inserted-image" /></a>');
});
// This checks for images that do not load //
$('img#monkey-inserted-image').error(function() {
$(this).removeAttr("id").attr("src", "/tamper/noimage1.png");
// If this image fails to load, an infinite loop is created //
});
});
ループを停止することを期待して.removeAttr()を使用してみましたが、停止しません。