From: Steinar H. Gunderson Date: Sat, 9 Dec 2006 16:23:34 +0000 (+0100) Subject: Fix some issues with IE preloading. X-Git-Url: https://git.sesse.net/?p=pr0n;a=commitdiff_plain;h=8139390f4df74822df8d485176bac88a66f912de Fix some issues with IE preloading. --- diff --git a/files/pr0n-fullscreen.js b/files/pr0n-fullscreen.js index 857f3d9..3a7dba6 100644 --- a/files/pr0n-fullscreen.js +++ b/files/pr0n-fullscreen.js @@ -96,12 +96,14 @@ function prepare_preload(img, width, height, evt, filename) preload.src = ""; preload.parentNode.removeChild(preload); } - - if (document.all) { // IE-specific - img.onload = "display_image(" + width + "," + height + ",\"" + evt + "\",\"" + filename + "\",\"preload\");"; + + // grmf -- IE doesn't fire onload if the image was loaded from cache, so check for + // completeness first; should at least be _somewhat_ better + if (img.complete) { + display_image(width, height, evt, filename, "preload"); } else { - img.onload = function() { display_image(width, height, evt, filename, "preload"); } - } + img.onload = function() { display_image(width, height, evt, filename, "preload"); }; + } } function relayout()