document.execCommand("BackgroundImageCache",false,true)

刺骨的言语ヽ痛彻心扉 2022-04-14 05:53 249阅读 0赞

IE6下的背景图片每次使用都会重新发送请求而不是使用本地缓存,特别是使用hover背景图片能明显感到到闪烁,有人用的办法解决了这个问题:

css方法:

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

js方法:

window.isIE=navigator.appName.indexOf(“Microsoft”)==0;
if(isIE){
document.documentElement.addBehavior(“#default#userdata”);
document.execCommand(“BackgroundImageCache”,false,true);
}

但其实该bug是有条件的,即IE的cache设置为Every visit to the page,而不是默认的Automatically。基本上,只有开发者才会把cache设置为每次访问检查更新,所以这个bug其实不会影响真正的用户 (根据在winxp sp2的ie6下测试,虽然可能仍然调用了一次网络存取的api,但是并没有发生实际的请求,症状就是鼠标有极短时间的抖动,但是图像 不会闪烁。

发表评论

表情:
评论列表 (有 0 条评论,249人围观)

还没有评论,来说两句吧...

相关阅读