Hi Faust,

Nice work! I suggest however that you change order of the parameters to
"path" "format". This is more logic.


> I have only tested this with Firefox 1.5 and IE 6.  ppk warned that IE
> on Windows does /not/ fire the |onload| event of cached images.  I did
> not notice any problems when returning to pages via the back button with
> IE.

This problem can easily be tackled for MSIE. You could (if
(jQuery.browser.msie) ...) add a random number to ensure the image from
loading. See my code at the bottom.

I am not sure you're code doesn't leak mem in IE. I've been reading so
much about this that i am a bit lost in the event binding stuff..

Here is my version:

jQuery.fn.jQIR = function(format, path) {
        var template = document.createElement('img');
        return this.each( function() {
                var obj = jQuery(this);

                // Prevent caching
                var url = path + obj.id() + '.' + format;
                if (jQuery.browser.msie) {
                        url+= '?' + (Math.round(512 * Math.random()) + 
Math.round(512 *
Math.random()));
                }

                // Change image
                jQuery(template.cloneNode(true)).oneload( function() {
                        obj.empty().append(this);
                }).attr( { src: url, alt: obj.text() } );
                obj = null;
        });
};

Basicly all i added was the random hack, cleaned up the code a bit, and
added the "obj = null;". Didn't test it cause i am at work now.

HTH,

Gilles


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to