站内搜索:
首页 >> 前端 >> 内容
html{filter:expression(document.execCommand(BackgroundImageCache,false,true)

时间:2013/11/20 8:25:31

IE6下的背景图片每次使用都会重新发送请求(not 本地),连一个hover效果时候同样的背景图片仅仅位置不同而已,ie6都会再次发送请求,这个令人崩溃的事情需要解决掉:

对于ie来说,filter:expression 很强大,能够实现的功能超级多,但是更对于视效率如生命的程序员来说,它的效率不敢令人恭维,所以有人会用css方法实现ie6下背景图片缓存,但是这种人也就是崇拜微软的强大而已,无它

有人会用css方法实现ie6下背景图片缓存:

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

当然大多数人都会选择js方法实现:

(function(){

try{

var userAgent = navigator.userAgent.toLowerCase();

var env = null;

var ver = 0;

env = userAgent.match(/msie ([\d.]+)/);ver = env ? parseInt(env[1], 10) : 0;

if(ver == 6){

try{

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

}catch(e){}

}

}catch(e){}

})();

 

  • 上一篇:console.table()调试javascript
  • 下一篇:CSS+DIV实现圆角
  • 返回顶部