zoukankan      html  css  js  c++  java
  • document.execCommand("BackgroundImageCache",false,true)解决ie6下的背景图片缓存问题

    E6下的背景图片每次使用都会重新发送请求(not 本地),连一个hover效果时候同样的背景图片仅仅位置不同而已,ie6都会再次发送请求,这个令人崩溃的事情需要解决掉:
    对于ie来说,filter:expression 很强大,能够实现的功能超级多,但是更对于视效率如生命的程序员来说,它的效率不敢令人恭维,所以有人会用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){}
    })();

    附:jQuery判断浏览器总结

    var isFF = (navigator.userAgent.toLowerCase().indexOf("firefox") != -1);
    var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
    var isIE6 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? true : false;
    var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
    var isChrome = (navigator.userAgent.indexOf("Chrome") != -1) ? true : false;
    var isSafari = (navigator.userAgent.indexOf("Safari") != -1) ? true : false;
    if (isIE6) {
        try { //IE6下缓存背景图片
             document.execCommand("BackgroundImageCache", false, true);
            } catch (e) {}
               }
  • 相关阅读:
    jquery利用event.which方法获取键盘输入值的代码
    C#计算某个时间距离当前日期的天数
    C#.net 货币格式转换
    用批处理来重启IIS的应用程序池
    C# .net 如何根据访问者IP获取所在地区
    C# 根据IP查询地址归属地
    windows Server 2008 IIS7 503错误解决方案
    技术选型
    bootstrap bable 自动换行问题
    .net 部署IIS 在服务器无法杀掉EXCEL进程
  • 原文地址:https://www.cnblogs.com/leejersey/p/3651795.html
Copyright © 2011-2022 走看看