<script> <BR><!-- <BR>var st="<img src=\"http://imgcache.qq.com/qzone/item/orig/11/3179_5.gif\" alt="IE 缓存策略的BUG的解决方法_javascript技巧" >" <BR>var ar = new Array(101); <BR>window.onload=function(){ <BR> document.body.innerHTML = ar.join(st); <BR>} <BR>//--> <BR></script>
用这段代码可以解决这个问题
<script> <BR>var imageholder=new Image() <BR>imageholder.src="http://imgcache.qq.com/qzone/item/orig/11/3179_5.gif" <BR></script>
<script> <BR>document.getElementById("div1").innerHTML = <BR>"<img id='p1' alt="IE 缓存策略的BUG的解决方法_javascript技巧" ><img id='p2' alt="IE 缓存策略的BUG的解决方法_javascript技巧" ><img id='p3' alt="IE 缓存策略的BUG的解决方法_javascript技巧" >"; <BR>document.getElementById("p1").src=imageholder.src; <BR>document.getElementById("p2").src=imageholder.src; <BR>document.getElementById("p3").src=imageholder.src; <BR></script>
这个bug的官方描述见:
http://support.microsoft.com/default.aspx?scid=kb;en-us;319546
此外 http://www.bazon.net/mishoo/Articles/msie/958/ 指出background-image会带来一样的问题。
ms的官方解决方案是象这样:
<script> <BR><!-- <BR>var st="<img src=\"http://imgcache.qq.com/qzone/item/orig/11/3179_5.gif" alt="IE 缓存策略的BUG的解决方法_javascript技巧" >http://imgcache.qq.com/qzone/item/orig/11/3179_5.gif\">" <BR>var ar = new Array(101); <BR>function test(){ <BR>document.getElementById("d").innerHTML = ar.join(st); <BR>document.getElementById("d").style.display="block"; <BR>} <BR>setTimeout("test()",1000); <BR>//--> <BR></script>
http://imgcache.qq.com/qzone/item/orig/11/3179_5.gif">
如果不怕麻烦的话,这样做可以更快一点点,也更保险:
<script> <BR><!-- <BR>var st="<img src=\"http://imgcache.qq.com/qzone/item/orig/11/3179_5.gif" alt="IE 缓存策略的BUG的解决方法_javascript技巧" >http://imgcache.qq.com/qzone/item/orig/11/3179_5.gif\">" <BR>var ar = new Array(101); <BR>function test(){ <BR>document.getElementById("d").innerHTML = ar.join(st); <BR>document.getElementById("d").style.display="block"; <BR>} <BR>//--> <BR></script>
http://imgcache.qq.com/qzone/item/orig/11/3179_5.gif" onreadystatechange="if(readyState=='complete')setTimeout('test()',0)">