Pixy方法受到IE的cache bug影响会闪烁。其实并没有说清楚这个问题,但其实该bug是有条件的,即IE的cache设置为Every visit to the page,而不是默认的Automatically。基本上,只有开发者才会把cache设置为每次访问检查更新,所以这个bug其实不会影响真正的用户 (根据在winxpsp2的ie6下测试,虽然可能仍然调用了一次网络存取的api,但是并没有发生实际的请求,症状就是鼠标有极短时间的抖动,但是图像 不会闪烁)。此外有人发现了一个未公开的方法来让IE对背景图进行缓存: document.execCommand("BackgroundImageCache",false,true)
用这种方法甚至避免了api调用,貌似是直接缓存在IE内存中。
IE6下设置背景图片是不会被真正cache住的,就算服务器做了cache,如果想cache住只能~~~
做过UI设计和开发的人一定知道,IE(不包括IE7)会经常从服务器端重新载入背景图片,好端端的UI界面在IE(不包括IE7)中就这样被折腾着......
Erik发现了一个简单的解决办法(针对IE7以下的IE有效,其实在IE7中已经修复了这个Bug)
程序代码
复制代码 代码如下:
document.execCommand("BackgroundImageCache", false, true);
今天阅读Ext的源码时发现Jack Slocum已经考虑到了这一点,在Ext.js中给出了他的实现,在其它Ajax框架中应该还没有这种类似的代码,从这一个细节上就能看出Ext的全面~
程序代码
复制代码 代码如下:
var isIE = ua.indexOf("msie") > -1, isIE7 = ua.indexOf("msie 7") > -1;
// remove css image flicker
if(isIE && !isIE7){
try{
document.execCommand("BackgroundImageCache", false, true);
}catch(e){}
}
今 天阅读幻宇的dreamplayer播放器源码时发现幻宇也针对IE的背景缓存进行了修复,只是他并没考虑到IE7中已经不存在这个现象了,这是 evml.js中的一段相关代码~(顺便嘀咕两句:这家伙,写JS从来不加分号的,以前是这样,现在还是这样,这样的话怎么进行压缩呀,汗~下面的代码按 照我的习惯都已加上分号,哪怕只有两三句而已~)
程序代码
复制代码 代码如下:
window.isIE=navigator.appName.indexOf("Microsoft")==0;
if(isIE){
document.documentElement.addBehavior("#default#userdata");
document.execCommand("BackgroundImageCache",false,true);
}
A while back a lot of people where covering how to work around the bug that IE always
reloads background images from the server, leading to your UI flickering.
Dean wrote one and lots of others wrote the same thing. Today, I saw this simple workaround
(from a fellow Googler who worked at Microsoft before):
document.execCommand("BackgroundImageCache", false, true)
Much simpler but makes me wonder why this is not the default setting?
/**
* 相关回复
* by Nicholas C. Zakas @2007-02-26
*/
I've actually wondered about this "bug" for a while.
I'm sure somewhere along the line this decision was made for a logical reason…
maybe they didn't anticipate how much background images would be used, or maybe they thought
there was some use case under which it would be desirable not to cache the background image.
I'm generally not big on overriding things that seem to be design decisions (which this seems to be).
I've never really thought this was a "bug"…bugs don't usually have switches that say "turn off bug".
用这种方法甚至避免了api调用,貌似是直接缓存在IE内存中。
IE6下设置背景图片是不会被真正cache住的,就算服务器做了cache,如果想cache住只能~~~
做过UI设计和开发的人一定知道,IE(不包括IE7)会经常从服务器端重新载入背景图片,好端端的UI界面在IE(不包括IE7)中就这样被折腾着......
Erik发现了一个简单的解决办法(针对IE7以下的IE有效,其实在IE7中已经修复了这个Bug)
程序代码
复制代码 代码如下:
document.execCommand("BackgroundImageCache", false, true);
今天阅读Ext的源码时发现Jack Slocum已经考虑到了这一点,在Ext.js中给出了他的实现,在其它Ajax框架中应该还没有这种类似的代码,从这一个细节上就能看出Ext的全面~
程序代码
复制代码 代码如下:
var isIE = ua.indexOf("msie") > -1, isIE7 = ua.indexOf("msie 7") > -1;
// remove css image flicker
if(isIE && !isIE7){
try{
document.execCommand("BackgroundImageCache", false, true);
}catch(e){}
}
今 天阅读幻宇的dreamplayer播放器源码时发现幻宇也针对IE的背景缓存进行了修复,只是他并没考虑到IE7中已经不存在这个现象了,这是 evml.js中的一段相关代码~(顺便嘀咕两句:这家伙,写JS从来不加分号的,以前是这样,现在还是这样,这样的话怎么进行压缩呀,汗~下面的代码按 照我的习惯都已加上分号,哪怕只有两三句而已~)
程序代码
复制代码 代码如下:
window.isIE=navigator.appName.indexOf("Microsoft")==0;
if(isIE){
document.documentElement.addBehavior("#default#userdata");
document.execCommand("BackgroundImageCache",false,true);
}
A while back a lot of people where covering how to work around the bug that IE always
reloads background images from the server, leading to your UI flickering.
Dean wrote one and lots of others wrote the same thing. Today, I saw this simple workaround
(from a fellow Googler who worked at Microsoft before):
document.execCommand("BackgroundImageCache", false, true)
Much simpler but makes me wonder why this is not the default setting?
/**
* 相关回复
* by Nicholas C. Zakas @2007-02-26
*/
I've actually wondered about this "bug" for a while.
I'm sure somewhere along the line this decision was made for a logical reason…
maybe they didn't anticipate how much background images would be used, or maybe they thought
there was some use case under which it would be desirable not to cache the background image.
I'm generally not big on overriding things that seem to be design decisions (which this seems to be).
I've never really thought this was a "bug"…bugs don't usually have switches that say "turn off bug".
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
暂无“IE图片缓存document.execCommand("BackgroundImageCache",false,true)”评论...
更新动态
2024年11月15日
2024年11月15日
- BIGFOUR.2013-大家利事【寰亚】【WAV+CUE】
- 李美凤.1992-情深透全情歌集【EMI百代】【WAV+CUE】
- 田震2024-《时光音乐会》[金峰][WAV+CUE]
- 群星《监听天碟3》[LECD]限量版[WAV+CUE]
- 心妤《声如夏花HQ》头版限量编号[WAV+CUE]
- 群星《摇滚五杰》[低速原抓WAV+CUE][1.1G]
- 群星 《2024好听新歌30》十倍音质 U盘音乐 [WAV+分轨]
- 群星《试音草原·女声篇》经典蒙古民歌[WAV+CUE][1G]
- 陈慧娴《永远是你的朋友》头版限量编号MQA-UHQCD2024[低速原抓WAV+CUE]
- 曼丽·女人三十《如果·爱》限量1:1母盘直刻[低速原抓WAV+CUE]
- 刘文正《流金三十年》[6N纯银镀膜][低速原抓WAV+CUE]
- 赵传.1994-精挑细选精选集【滚石】【WAV+CUE】
- 郑亚弦.2024-隔壁包厢603(EP)【发现梦想】【FLAC分轨】
- 文章.2004-被遗忘的时光【华博音乐】【WAV+CUE】
- 群星《青葱韶歌》原力计划·毕业季企划合辑[FLAC+分轨][661M]