IE6下的背景图片用的时候都会再次发送请求,就连一个hover效果同样的背景图片只是位置不同,ie6都会再次请求,这个令人崩溃的事情需要解决掉:
css写法:
html
{
filter
:
expression(document.execCommand("BackgroundImageCache", false, true))
;
}
注意:
expression严重影响效率,
强烈建议不要用。
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){}
})();
转自:http://shuiwangliu.blog.163.com/blog/static/1645857452010719104817563/