Treehouse: Grow your CSS skills. Land your dream job.

Last updated on:

Prevent Background Image Flickering in IE

try {
 document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

Comments

  1. paul
    Permalink to comment#

    i really like this blog, keep making!!

  2. Leonard Michael

    Silly question perhaps, but how do you use/implement this?

    Example?

    • Zach
      Permalink to comment#

      I believe you just put it in your head, like this:

      try {
      document.execCommand(“BackgroundImageCache”, false, true);
      } catch(err) {}

    • Zach
      Permalink to comment#

      [script type=”javascript”]
      try {
      document.execCommand(“BackgroundImageCache”, false, true);
      } catch(err) {}
      [/script]

      Sub in the real brackets in the code

  3. saverio

    graet

  4. sujji
    Permalink to comment#

    hi,
    i used the above code . but still i am facing image flickering. i have to place the names of the images in the place of BackgroundImageCache. please help me

    • Gatis Kaulinsh
      Permalink to comment#

      I am changing background images in realtime and before it i have great code to preload all my Website images but it does not help. This code does not help either. I am pretty sure at 100% that it can’t be fixed at all.

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in in triple backtick fences like this:

```
<script>
  function example() {
    element.innerHTML = "<div>code</div>";
  }
</script>
```