IE6: Background-Image Load Event

前端 未结 4 1193
独厮守ぢ
独厮守ぢ 2021-02-12 21:26

I am displaying a bunch of thumbnail images and the latency can be very high (over a VPN) so I send all the thumbnails in a single file (like a sprite) and set the CSS backgroun

4条回答
  •  既然无缘
    2021-02-12 22:04

    you have to first insert into DOM, then attach to the img.load event, then put src and all should work in IE. The problem is because IE doesn't fire onload event always if src is set before the onload handler.

    $('').appendTo('body').load(function() {
        $('.Thumbnails').css('background-image', 'url(ThumbSpriteTest.png)');
    }).attr('src', 'ThumbSpriteTest.png');
    

提交回复
热议问题