IE6: Background-Image Load Event

前端 未结 4 1200
独厮守ぢ
独厮守ぢ 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:00

    1) css property:

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

    2) attr('src', 'ThumbSpriteTest.png') - may be a problem

    The values of some attributes are reported inconsistently across browsers, and even across versions of a single browser. The .attr() method reduces such inconsistencies.

    See http://api.jquery.com/attr/

    3) Also:

    
    

    OR try CSS way

    html { 
    filter: expression(document.execCommand("BackgroundImageCache", false, true)); 
    }
    

    last examples were found here: Jquery IE6 hover problems, keeps loading background image

提交回复
热议问题