Internet Explorer innerHTML Quirk

I admit it: when I hit a wall programming I type a few words into Google and click on the first few results. Very rarely have I ever looked at the Microsoft Knowledge Base. But every once in a while someone will forward me an article from there and I’m just left thinking, “damn.”

Case in point, did you know that when you insert img tags into a document using innerHTML that the images are re-requested from the server and not used from the cache? According to this article, this functionality is “by design” in Internet Explorer and won’t be fixed. Well, it’s good to know that this happens but why is that how it should behave? Shouldn’t you always be using cached data whenever possible? What’s even more annoying is that the solutions they give aren’t really practical. Sometimes you don’t know what images will be loaded, so there’s no way to preload them. The second proposed solution, to provide a time delay, doesn’t explain how one would go about creating such functionality. Argh.

Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.

Subscribe to the mailing list

Email Address

Send me:

Blog posts

Updates

José Jeria

I wonder why they dont mention versions prior to 5.5 (5.0 for example that we still support in our company). I wonder if it's because it worked differently there or because they dont support prior versions anymore…

Nicholas C. Zakas

I'd be willing to bet that's probably the case. Microsoft is infamous for cutting off support for older products (witness the hoopla over them ending Visual Basic 6 support).