2011-02-03 112 views
1

我尝试两种不同的技术对IE7,IE8预载图片

url = 'http://domain.com/image.gif'; 
$('body').append('<img style="display:none" src="'+url+'" />'); 

image = Image(1,1); 
image.src = 'http://domain.com/image.gif'; 

形象得到IE6,Chrome浏览器预装8,火狐3.5 +

但无法让这些工作在IE8或IE7中


任何想法?

+0

不要设置显示:无 - 也许IE正在优化它一些奇怪的方式;只是不要将图像附加到身体上,它不会显示 – Andrey 2011-02-03 17:46:33

+0

@Andrey:我的服务器上没有显示http调用,每次页面加载时图像URL都会发生变化 – RadiantHex 2011-02-03 17:48:15

回答

1

有一个jQuery plugin做你想做的。

另一种方法是只有当整个DOM(包括图像本身)已被加载时,才能进行jQuery图像处理,例如,而不是

$(window).ready(function(){..... 

使用

$(window).load(function(){..... 

the documentation