Fix some issues with IE preloading.
authorSteinar H. Gunderson <sesse@debian.org>
Sat, 9 Dec 2006 16:23:34 +0000 (17:23 +0100)
committerSteinar H. Gunderson <sesse@debian.org>
Sat, 9 Dec 2006 16:23:34 +0000 (17:23 +0100)
files/pr0n-fullscreen.js

index 857f3d9c27d654801199142459c933ea60a5277e..3a7dba62e0c6bbed2653928d8bdeccc7d576776b 100644 (file)
@@ -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()