Background image caching in IE6

Time:2021-6-7

Bug of CSS background image flashing in IE6

Every time the background image in IE6 is used, the request (non local) will be sent again. Even when a hover effect is used, the same background image only has different positions. IE6 will send the request again. This crashing thing needs to be solved
For ie, filter:expression It’s very powerful. It can achieve many functions, but for programmers who regard efficiency as life, its efficiency is not flattering, so some people will use CSS method to cache background images under IE6, but this kind of people just adore the power of Microsoft

Copy code

The code is as follows:

html { filter:expression (document.execCommand(“BackgroundImageCache”, false, true));} Disadvantages: it may slow down the loading speed of the whole page

Most people will choose the JS method to implement:

Copy code

The code is as follows:

<script type=’text/javascript’>
document.execCommand(“BackgroundImageCache”, false, true);
</script>

Disadvantages: if it is executed in a browser such as firebox, there will be an error.

Therefore, it is necessary to determine whether it is an IE browser. The methods provided by jQuery are as follows:

Copy code

The code is as follows:

<script type=’text/javascript’>
if ($.browser.msie) {
document.execCommand(“BackgroundImageCache”, false, true);
}
</script>

More simply, use IE’s conditional comments:

Copy code

The code is as follows:

<!–[if lt IE 7]>
<script>document.execCommand(“BackgroundImageCache”,false,true);</script>
<![endif]–>

Recommended Today

Swift advanced (XV) extension

The extension in swift is somewhat similar to the category in OC Extension can beenumeration、structural morphology、class、agreementAdd new features□ you can add methods, calculation attributes, subscripts, (convenient) initializers, nested types, protocols, etc What extensions can’t do:□ original functions cannot be overwritten□ you cannot add storage attributes or add attribute observers to existing attributes□ cannot add parent […]