现在的位置: 首页 > 综合 > 正文

IE6不缓存背景图片的两种解决方案

2013年03月22日 ⁄ 综合 ⁄ 共 355字 ⁄ 字号 评论关闭

     IE默认情况下不缓存背景图片,所以当鼠标在有CSS背景的按钮或是图片上移动时,图片会重新加载,增加很多没必要的请求,加重服务器的负担。

  以下是两种解决方案,推荐使用第一种

  方法一:在页面加入以下javascript代码

<!--[if IE 6]>
    <script type="text/javascript">
     try{         
      document.execCommand('BackgroundImageCache',false,true);
    }catch(e){}   </script> <![endif]-->

 

  方法二:css表达式

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

 

抱歉!评论已关闭.