zoukankan      html  css  js  c++  java
  • document.execCommand(”BackgroundImageCache”, false, true)

    很多时候我们要给一些按钮或是img设置背景,而为了达到数据与表现样式分离的效果,通常背景样式都是在CSS里设定的,但是这个行为在IE会有一 个Bug,那就是因为 IE默认情况下不缓存背景图片,所以当鼠标在有CSS背景的按钮或是图片上移动时,图片会闪烁甚至鼠标会出现忙的状态,而在FireFox下没有这个问 题,为了解决这个问题,有两种解决办法,其一是在CSS中加入如下样式:

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

    但这个可能会使整个页面的加载变得很慢,所以推荐使用JS来修正这个Bug,在页面中的任意位置加入如下代码,即可达到理想中的效果:

    (function(){
    var browser=new Object();
    browser.name=navigator.appName;
    if(browser.name.indexOf("Microsoft")!=-1){
    browser.version=navigator.appVersion.indexOf("MISE");
    browser.version=parseInt(navigator.appVersion.substring(browser.version+4));
    if(browser.version<=6){
    document.execCommand("BackgroundImageCache",false,true);
    }
    }
    })(window.navigator);

  • 相关阅读:
    Leetcode#129 Sum Root to Leaf Numbers
    Leetcode#15 3Sum
    Leetcode#16 3Sum Closest
    Leetcode#127 Word Ladder
    Leetcode#2 Add Two Numbers
    Leetcode#18 4Sum
    vue.js入门(3)——组件通信
    vue.js慢速入门(2)
    vue 基础介绍
    vue.js中v-for的使用及索引获取
  • 原文地址:https://www.cnblogs.com/rainbow661314/p/3204777.html
Copyright © 2011-2022 走看看