zoukankan      html  css  js  c++  java
  • 解决IE6背景图片不缓存的问题

    IE6在背景图片缓存上有一个bug:它会每次都从服务器端读取背景图片。例如我们使用a:hover更换背景图片,在IE6下会出现每次鼠标滑过 则重新向服务器请求图片,如果服务器反应较慢,那么hover效果就会出现短暂的空白,令人极度不爽。虽然可以通过CSS sprites的方式解决问题的,但效果差强人意。 示例: a{ background:url(normal.gif); } a:hover { background:url(hover.gif); } 如果为超级链接定义上述的css样式以实现鼠标悬浮时的动态效果,在firefox下是没有什么问题的,第一次加载之后,浏览器都会从缓存读取背景图片. 解决方法 具体的解决方法就是在页面中加入一段简单的javascript脚本,告诉IE6:本地有背景图片的话就不要麻烦服务器了。 document.execCommand(“BackgroundImageCache”,false,true); 关于这段脚本的放置方式有两种:

    1.使用CSS,在CSS中加入如下代码 html {}{ filter: expression(document.execCommand(“BackgroundImageCache”, false, true)); }

    2.使用JS: document.execCommand(“BackgroundImageCache”,false,true);

  • 相关阅读:
    UVALive 7141 BombX
    CodeForces 722D Generating Sets
    CodeForces 722C Destroying Array
    CodeForces 721D Maxim and Array
    CodeForces 721C Journey
    CodeForces 415D Mashmokh and ACM
    CodeForces 718C Sasha and Array
    CodeForces 635C XOR Equation
    CodeForces 631D Messenger
    田忌赛马问题
  • 原文地址:https://www.cnblogs.com/shihao/p/2179359.html
Copyright © 2011-2022 走看看